Request():setFileContent()
Attach content the macro already holds as if it were an uploaded file.
Signature
setFileContent(name: string, fileName: string, content: string): Request
setFileContent(name: string, fileName: string, content: string, contentType: string): Request
Parameters
| Parameter | Type | Description |
|---|---|---|
| name | string | Form field name the server expects |
| fileName | string | File name shown to the server |
| content | string | File content as a UTF-8 string |
| contentType | string | Optional MIME type, for example text/plain |
Returns
Request, so calls chain.
Description
The content is encoded as UTF-8 bytes; it is not base64-decoded. For binary files, build the
bytes yourself or use the app's file upload flow instead. When a request has file content, the
parameters and files are sent as a multipart/form-data body.
Example
Request("https://api.example.com/upload")
:setFileContent("file", "note.txt", "hello from a macro", "text/plain")
:post()
Compatible Version: 1.0.0.37 and up