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
Future<(APIResponse, ZCatalystFile)> <FOLDER_INSTANCE>.uploadFile(String filePath, String fileName)

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 try{ var (response, file) = await folder.uploadFile( 'assets/images/product_image.jpg', 'sample_product'); print('File Upload Success: ${file.name}'); } on ZCatalystException catch (ex) { print(ex.toString()); }

Last Updated 2024-09-12 18:16:13 +0530 +0530