saveFile
The saveFile action saves media files (e.g., images) to the default media storage and documents to the default documents directory on Android and IOS. On the web, it downloads the file to the browser's default download folder.
Properties
| Property | Type | Description |
|---|---|---|
| source | string | The source URL of the file |
| blobData | string | Blob data of the file in base64 string |
| type | string | Type of the file which are image or document. If type is document then the action will consider the source or blobData to be of document file and will save the file in the default device document folder |
| onComplete | action | Action to be executed on successful file saving on mobile device and successful downloading on web |
| onError | action | Action to be executed on error saving file |
Example
1. For blobData input:
In case the type is image, action will save image in default Pictures path of device, in case of web, it will download the file
Button:
onTap:
saveFile:
fileName: 'Test.png'
type: image
blobData: # blob string for imageIn case the type is document, action will save document in default Documents path of device, in case of web, it will download the file
In case the type is document, it'll be saved in Documents
Button:
onTap:
saveFile:
fileName: 'Test.pdf'
type: document # pdf, docx, txt
blobData: # blob string for document
onComplete:
showToast:
message: File saved successfuly
onError:
showToast:
message: File saving failed2. For source input:
Button:
onTap:
saveFile:
fileName: 'Test.pdf'
type: document # pdf, docx, txt
source: https://pdfobject.com/pdf/sample.pdf # source-url for document
onComplete:
showToast:
message: File saved successfuly
onError:
showToast:
message: File saving failedYou can try complete example here (opens in a new tab)