Actions
Save File

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

PropertyTypeDescription
sourcestringThe source URL of the file
blobDatastringBlob data of the file in base64 string
typestringType 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
onCompleteactionAction to be executed on successful file saving on mobile device and successful downloading on web
onErroractionAction 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 image

In 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 failed

2. 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 failed

You can try complete example here (opens in a new tab)