Upload a File

You can upload a file to an existing folder in the File Store, by calling the uploadFile() method. After the file is uploaded in the folder, a unique File ID will be generated for it. You can upload an image, text document, CSV, or any other type of file you need.

The <FOLDER_INSTANCE> used in the code sections of all the methods below is the instance defined in the Folder Instance page. This will refer to the folder that the file must be uploaded in.

    
copy
<FOLDER_INSTANCE>.uploadFile( String filePath, String fileName, void Function(ZCatalystFile) onSuccess, void Function(ZCatalystException) onFailed, void Function(int, int, double) inProgress )

Parameters:

  • filepath: The file path of the file to be uploaded
  • fileName: The name of the file to be uploaded

A sample code snippet with the folder instance is shown below:

    
copy
ZCatalystFolder folder = ZCatalystApp.getInstance() .getFileStoreInstance() .getFolderInstance(2823000000006561); //Define the folder instance and specify the ID of the folder to upload the file in folder.uploadFile( 'assets/images/product_image.jpg', 'sample_product', //Pass the file path and the file name to the uploadFile() method (APIResponse response, ZCatalystFile file) { print('File Upload Success: ${file.name}'); //Actions to be executed upon success }, (ZCatalystException exception) { print('File Upload has failed: ${exception}'); //Actions to be executed upon failure }, );

Last Updated 2023-12-15 18:54:08 +0530 +0530