ProxymanApp / Proxyman

Modern. Native. Delightful Web Debugging Proxy for macOS, iOS, and Android ⚡️
https://proxyman.io
5.35k stars 177 forks source link

File system access from within scripts. #1969

Open foxt opened 3 months ago

foxt commented 3 months ago

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

NghiaTranUIT commented 3 months ago

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