Proxyman icon indicating copy to clipboard operation
Proxyman copied to clipboard

File system access from within scripts.

Open foxt opened this issue 1 year ago • 1 comments

Description

It would be great to have file system access within the script system.

Why this feature/change is important?

Currently if you want to reply with binary data you have to embed the base64 data inside the file, which can cause instability within Proxyman with large files. For this case it would be helpful to be able to read a file from the filesystem and use this as the request body/response body

foxt avatar Mar 14 '24 00:03 foxt

@foxt It's quite easy when using response.bodyFilePath property. Here is the example:

function onResponse(context, url, request, response) {
 
  response.headers["Content-Type"] = "image/png";
  response.bodyFilePath = "~/Desktop/image.png";
 
  // Done
  return response;
}
  • Snipped Code: https://docs.proxyman.io/scripting/snippet-code#map-a-local-file-to-responses-body-like-map-local-tool-proxyman-2.25.0

  • Make sure to override your Content-Type header to match with the type of your body 👍

NghiaTranUIT avatar Mar 14 '24 02:03 NghiaTranUIT