Request():setFileContent()
매크로가 이미 보유한 콘텐츠를 업로드한 파일처럼 첨부합니다.
시그니처
setFileContent(name: string, fileName: string, content: string): Request
setFileContent(name: string, fileName: string, content: string, contentType: string): Request
매개변수
| 매개변수 | 유형 | 설명 |
|---|---|---|
| name | string | 서버가 기대하는 폼 필드 이름 |
| fileName | string | 서버에 표시되는 파일 이름 |
| content | string | UTF-8 문자열로 된 파일 콘텐츠 |
| contentType | string | 선택 사항인 MIME 유형. 예: text/plain |
반환값
호출을 체이닝할 수 있도록 Request를 반환합니다.
설명
콘텐츠는 UTF-8 바이트로 인코딩되며 base64로 디코딩되지 않습니다. 바이너리 파일의 경우 바이트를
직접 만들거나 앱의 파일 업로드 흐름을 사용하세요. 요청에 파일 콘텐츠가 있으면 매개변수와 파일이
multipart/form-data 본문으로 전송됩니다.
예시
Request("https://api.example.com/upload")
:setFileContent("file", "note.txt", "hello from a macro", "text/plain")
:post()
호환 버전: 1.0.0.37 이상