Proxyman
Proxyman copied to clipboard
[Scripting] Appending a current file with `writeToFile`
Description
Currently, the writeToFile() in the Scripting will override the existed file.
function onResponse(context, url, request, response) {
// Write to single file
writeToFile(response.body, "~/Desktop/body.json");
// Write the Body to file with flow ID
writeToFile(response.body, "~/Desktop/sample-" + context.flow.id);
// Done
return response;
}
=> Some users would like to append content to the current file, not override them.
Acceptance Criteria
- Able to Override or Append to the current file
Done with: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_3.6.0_writeToFile_by_appending.dmg
Sample
async function onResponse(context, url, request, response) {
var opt = {appendFile: true}
writeToFile(response.body, "~/Desktop/body.json", opt);
// Done
return response;
}