Proxyman icon indicating copy to clipboard operation
Proxyman copied to clipboard

[Scripting] Appending a current file with `writeToFile`

Open NghiaTranUIT opened this issue 3 years ago • 1 comments

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

NghiaTranUIT avatar Jun 28 '22 07:06 NghiaTranUIT

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;
}

NghiaTranUIT avatar Jun 28 '22 07:06 NghiaTranUIT