http.downloadFile
http.downloadFile(url, id, filename)
Description
Downloads a file through HTTP to disk. Uses USER and PASSWORD parameters if present. Uses headers defined.
Returns an attachment object with path to the file downloaded in disk.
Parameters
| Parameter | Type | Explanation |
|---|---|---|
| url | String | The endpoint to call to download the file |
| id | String | The id of the ticket. Used to generate the folder name where to download the file |
| filename | String | The name of the file |
Example
// A text file: https://www.w3.org/TR/PNG/iso_8859-1.txt
// A PDF file: https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf
url = "https://www.w3.org/2008/site/images/logo-w3c-mobile-lg"
http = option.http
http.rest.addParam("endpoint","HTTP")
attachment = http.downloadFile(url, "1", "logo-w3c-mobile-lg.png")
println attachment.getFilename()
println attachment.getBase64()
msg = api.newMessage("HelloMessageType")
msg.put("text", "Hello world")
msg.put("attachments/0", attachment)
api.publish(msg)