How to save an attachment returned from an api?

There is an export api can export all users as an excel file,
I want to save it and use it for import api, how can I do?
Please give me some suggestion~

Hello Jessie! Can you be more specific about what you want to do? Do you mind giving an example workflow across the overall k6 test life cycle?

An early guess:

  1. In the init stage, export the users as a CSV.

  2. (Still in init), combine papaparse with a SharedArray to turn the CSV file into an array that your VUs can reference.

    Example of the exact procedure of this step

  3. In the default function, run your VU code and use the CSV-turned-array data as you wish.

If you want to write the API response to a file, you may need to use an extension.
This post explains why, and links some viable extensions: Write data to file - #2 by imiric

I hope that puts you on the right track! If not, at least that’s two for the process of elimination :slight_smile: .

Really appreciate for your reply!
I’m trying to use k6 for single-interface performance testing, so exporting and importing users are two separate scripts.
Sending a get request when exporting users, and get response like this:



1.Can I get the attachment and save it ?
2.If I save response with file.writeString(path, res.body), how can I use it for importing?

Importing user like this

image