store_file
store_file Stores a file the app made on the device (a PDF it built, a CSV it assembled, a text it composed) in the app's database as a storedCloudFile, exactly as fileprompt stores a file the user picked, and returns that cloud object (with its url, which opens only for this session: see fileprompt). No dialog is shown.
Runs on: either side: the compiler places the statement that calls it where the values it uses live.
Client side — The file is built and sent from the device; the statement runs on the device.
The data is kept in the app's database — As for fileprompt, the file's data lives in the app's database and goes with the object when it is deleted with delete().
Format:
store_file(file_name, content [, mime_type])
Parameters:
| Parameter | Type | Description |
|---|---|---|
| The | file_name | name to store the file under, with its extension; the extension decides whether the file is accepted (pdf, txt, csv, json, xml, html, css, js, svg, png, jpg, bmp, ttf, woff, mp4, mp3). |
| The | content | file's data: a string (text; the mime type defaults to text/plain), a data: URL (for example the output of a PDF library, or a canvas), a Blob or File from a JS block, or an ArrayBuffer. |
| The | mime_type |  [Optional]content type to store the file with when the content is a string or an ArrayBuffer (for example "text/csv"). |
Returned Value:
| Type | Description |
|---|---|
| the | storedCloudFile cloud object, or FALSE when the store failed, in which case upload_error holds the message (an alert is shown). |
Examples
report = store_file("summary.pdf", pdf_data_url, "application/pdf")
if (report) { send_mail(customer_email, "Your summary", "Your summary is attached.", from_address, true, report) }