[GH-ISSUE #1298] writeToFil Unable to append file in new line(想要在文件追加信息) #1294

Closed
opened 2026-03-03 19:50:10 +03:00 by kerem · 4 comments
Owner

Originally created by @jihtsan on GitHub (Jul 16, 2022).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1298

Proxyman version? (Ex. Proxyman 1.4.3)

Proxyman 3.6.2

macOS Version? (Ex. mac 10.14)

Mac(12.4)

Steps to reproduce

image

but after the response file is:
image

Expected behavior

  1. response body append in target file and have new line;

Screenshots (optional)

Originally created by @jihtsan on GitHub (Jul 16, 2022). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1298 ### Proxyman version? (Ex. Proxyman 1.4.3) Proxyman 3.6.2 ### macOS Version? (Ex. mac 10.14) Mac(12.4) ### Steps to reproduce <img width="592" alt="image" src="https://user-images.githubusercontent.com/20720673/179355220-34e6ac76-979a-4c2a-9cdd-cc5aeeb68087.png"> but after the response file is: <img width="593" alt="image" src="https://user-images.githubusercontent.com/20720673/179355294-199297d3-6022-4823-9002-1c91ffe5aa8a.png"> ### Expected behavior 1. response body append in target file and have new line; ### Screenshots (optional)
kerem closed this issue 2026-03-03 19:50:10 +03:00
Author
Owner

@NghiaTranUIT commented on GitHub (Jul 16, 2022):

@jihtsan please provide the var opt = {appendFile: true} to the writeToFile

async function onResponse(context, url, request, response) {

  // Append to the existed file
  // Or create a new file if it doesn't exist
  var opt = {appendFile: true}
  writeToFile(response.body, "~/Desktop/body.json", opt);

  // Done
  return response;
}

If you don't provide the opt, it will override the file 👍

Ref: https://docs.proxyman.io/scripting/snippet-code#write-export-to-a-local-file

<!-- gh-comment-id:1186181569 --> @NghiaTranUIT commented on GitHub (Jul 16, 2022): @jihtsan please provide the `var opt = {appendFile: true}` to the `writeToFile` ```js async function onResponse(context, url, request, response) { // Append to the existed file // Or create a new file if it doesn't exist var opt = {appendFile: true} writeToFile(response.body, "~/Desktop/body.json", opt); // Done return response; } ``` If you don't provide the `opt`, it will override the file 👍 Ref: https://docs.proxyman.io/scripting/snippet-code#write-export-to-a-local-file
Author
Owner

@jihtsan commented on GitHub (Jul 17, 2022):

I think , but this code didn't in new line ,so i want to append '\n' .

<!-- gh-comment-id:1186374972 --> @jihtsan commented on GitHub (Jul 17, 2022): I think , but this code didn't in new line ,so i want to append '\n' .
Author
Owner

@jihtsan commented on GitHub (Jul 18, 2022):

image this can fix it. response.body is jsonobject , i didnt know how to convert to jsonString
<!-- gh-comment-id:1186814982 --> @jihtsan commented on GitHub (Jul 18, 2022): <img width="608" alt="image" src="https://user-images.githubusercontent.com/20720673/179455821-5479b7a2-b343-47d2-b381-b1abce9d21a7.png"> this can fix it. response.body is jsonobject , i didnt know how to convert to jsonString
Author
Owner

@jihtsan commented on GitHub (Jul 18, 2022):

close issue

<!-- gh-comment-id:1186815220 --> @jihtsan commented on GitHub (Jul 18, 2022): close issue
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Proxyman#1294
No description provided.