Upload a File

Note: Catalyst now offers you a brand new object storage component called Stratus in Early Access mode. This component is a significant upgrade to the current Cloud Scale File Store component. You can find out more about the Stratus component here.

To use the Stratus component in the Early Access mode, email us at support@zohocatalyst.com.

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 type of file you need upto 100MB of file size.

You can upload the file in one of the following five ways, as discussed below. 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.

By passing the File URI Scheme

You can upload the file to the folder of the given folder instance by passing the file’s URI scheme as an argument to the uploadFile() method:

    
copy
<FOLDER_INSTANCE>.uploadFile(
uri: Uri,
success: (ZCatalystFile) → Unit,
failure: ((ZCatalystException) → Unit)?,
progress: ((Long, Long, Double) → Unit)?
): ZCatalystRequest<ZCatalystResponse<ZCatalystFile>>?

Parameters:

  • uri: The File URI scheme of the file to be uploaded

A sample code snippet is shown below:

    
copy
ZCatalystApp.getInstance().getFileStoreInstance().getFolderInstance(2823000000006561).uploadFile("/src.example.com/files/productImage.png",
{
println(" >> File Upload Success -$it")
},
{
println(" >> File Upload Failed -$it")
})

By passing the File Path

You can upload the file to the folder of the given folder instance by passing its file path in the local system an argument to the uploadFile() method:

    
copy
<FOLDER_INSTANCE>.uploadFile(
filePath: String,
success: (ZCatalystFile) → Unit,
failure: ((ZCatalystException) → Unit)?,
progress: ((Long, Long, Double) → Unit)?
): ZCatalystRequest<ZCatalystResponse<ZCatalystFile>>?

Parameters:

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

A sample code snippet is shown below:

    
copy
ZCatalystApp.getInstance().getFileStoreInstance().getFolderInstance(2823000000006561).uploadFile("/Desktop/HelplineCard.webp",
{
println(" >> File Upload Success -$it")
},
{
println(" >> File Upload Failed -$it")
})

By passing the File URI Scheme and File Name

You can upload the file to the folder of the given folder instance by passing both File URI scheme and the file name as individual arguments to the uploadFile() method:

    
copy
<FOLDER_INSTANCE>.uploadFile(
uri: Uri,
fileName: String,
success: (ZCatalystFile) → Unit,
failure: ((ZCatalystException) → Unit)?,
progress: ((Long, Long, Double) → Unit)?
): ZCatalystRequest<ZCatalystResponse<ZCatalystFile>>?

Parameters:

  • uri: The File URI scheme of the file to be uploaded
  • fileName: The name of the file to be uploaded

A sample code snippet is shown below:

    
copy
ZCatalystApp.getInstance().getFileStoreInstance().getFolderInstance(2823000000006561).uploadFile("/src.example.com/files", "productImage.png",
{
println(" >> File Upload Success -$it")
},
{
println(" >> File Upload Failed -$it")
})

By passing the File Path and File Name

You can upload the file to the folder of the given folder instance by passing both the file path in the local system and the file name as the arguments to the uploadFile() method:

    
copy
<FOLDER_INSTANCE>.uploadFile(
filePath: String,
fileName: String,
success: (ZCatalystFile) → Unit,
failure: ((ZCatalystException) → Unit)?,
progress: ((Long, Long, Double) → Unit)?
): ZCatalystRequest<ZCatalystResponse<ZCatalystFile>>?

Parameters:

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

A sample code snippet is shown below:

    
copy
ZCatalystApp.getInstance().getFileStoreInstance().getFolderInstance(2823000000006561).uploadFile("/Desktop", "HelplineCard.webp",
{
println(" >> File Upload Success -$it")
},
{
println(" >> File Upload Failed -$it")
})

By passing the File as inputStream and the File Name

You can upload the file to the folder of the given folder instance by passing both the file as inputStream and the file name as the arguments to the uploadFile() method:

    
copy
<FOLDER_INSTANCE>.uploadFile(stream: InputStream,
fileName: String,
success: (ZCatalystFile) -> Unit,
failure: ((ZCatalystException) -> Unit)? = null,
progress: ((bytesWritten: Long, contentLength: Long, percentage: Double) -> Unit)? = null)
: ZCatalystRequest<ZCatalystResponse<ZCatalystFile>>?

Parameters:

  • stream: The inputStream of the file
  • fileName: The name of the file to be uploaded

A sample code snippet is shown below:

    
copy
val file = File("/Desktop/HelplineCard.webp")
val inputStream: InputStream = FileInputStream(file)
ZCatalystApp.getInstance().getFileStoreInstance().getFolderInstance(2823000000006561).uploadFile(inputStream,
{
println(" >> File Upload Success -$it")
},
{
println(" >> File Upload Failed -$it")
})

Last Updated 2025-02-24 14:38:44 +0530 +0530

ON THIS PAGE
ACCESS THIS PAGE