Proxyman
Proxyman copied to clipboard
File system access from within scripts.
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 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-Typeheader to match with the type of your body 👍