Get Files

Get the Metadata of a Specific File

You can retrieve the details of a specific file in the File Store, by passing its unique File ID as an argument to the getFile() method, as shown in the code syntax below. This fetches the file object using which you can retrieve the file’s metadata such as the details of its creation, last modification, file size, etc.

The <FOLDER_INSTANCE> used in the code below is the instance defined in the Folder Instance page.

    
copy
<FOLDER_INSTANCE>.getFile( fileId : Int64, completion : @escaping ( Result< ZCatalystFile, ZCatalystError > ) -> Void )

Parameters:

  • id: The unique File ID of the file to be retrieved

  • completion: If the operation is successful, the completion block will return with the file details. Else, it will return an error.

A sample code snippet is shown below:

    
copy
ZCatalystApp.shared.getFileStoreInstance().getFolderInstance(id : 105000000121098) .getFile(fileId : 332000000044009){(result) in //Replace this with your Folder ID and File ID switch result { case .success ( let file) : print("The name of the file is " + file.name) case .error( let error ) : print( "Error occurred >>> \( error )" ) } }

Get the Metadata of all Files

You can retrieve the details of all the files available in a specific folder using the getFiles() method, as shown in the code syntax below.

The <FOLDER_INSTANCE> used in the code below is the instance defined in the Folder Instance page.

    
copy
<FOLDER_INSTANCE>.getFiles( completion : @escaping ( Result< [ ZCatalystFile ], ZCatalystError > ) -> Void )

Parameters:

  • completion: If the operation is successful, the completion block will return the details of all the files. Else, it will return an error.

A sample code snippet is shown below:

    
copy
ZCatalystApp.shared.getFileStoreInstance().getFolderInstance(id : 105000000121098) .getFiles {(result) in //Replace this with your Folder ID switch result { case .success ( let files) : for file in files{ print("The names of the folder are \(file.name)") } case .error( let error ) : print( "Error occurred >>> \( error )" ) } }

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