Delete a File

You can delete an existing file from a folder in the File Store by calling the delete() method and referring to the file with the file instance. This will delete the file permanently.

The <FILE_INSTANCE> used in the code below is an instance created for the specific file, as shown in the sample code snippet. This will refer to the file that must be deleted by its unique File ID.

    
copy
<FILE_INSTANCE>.delete( void Function() onSuccess, void Function(ZCatalystException) onFailed )

A sample code snippet is shown below:

    
copy
ZCatalystFolder folder = ZCatalystApp.getInstance() .getFileStoreInstance() .getFolderInstance(2823000000006561); folder.getFile( 2823000000006561, //Define the file instance with the Folder ID and File ID (APIResponse response, ZCatalystFile file) { file.delete( onSuccess: (APIResponse response) { print('File deleted successfully.'); //Actions to be executed upon a successful deletion }, onFailed: (ZCatalystException exception) { print('Failed to delete the file: $exception'); //Actions to be executed upon failure }, ); }, (ZCatalystException exception) { print('Get File failed: $exception'); //Actions to be executed upon failure in fetching the file instance }, );

Last Updated 2023-09-03 01:06:41 +0530 +0530