Android SDK Samples - Files Operations

Download File from ZFS(Zoho Files System)
          
          
val refId = "downloadFile" + System.currentTimeMillis().toString()

val filepath = "File(filename).absolutePath"

//Call downloadFile() by passing the fileRequestRefId, fileId, filePath and fileName as parameters

//fileRequestRefId - reference id which is used as a tag to this api request

//fileId: id of the file

//filePath - path where the file should be downloaded

//fileName - name of the file should be downloaded

ZCRMSDKUtil.downloadFile(refId,"a7168f6axxx26f1c5f49",filepath,"enable-signals.png",object:FileWithDataTransferTask<FileAPIResponse,String>
{
   override fun onCompletion(response: FileAPIResponse, zcrmEntity: String) {
       println("${response.responseJSON}")
   }

   override fun onFailure(exception: ZCRMException) {
       println("Throws Exception : $exception")
   }

   override fun onProgressUpdate(bytesWritten: Long,contentLength: Long,percentage: Double) {
       println("OnProgress Update : ${bytesWritten}+${contentLength}+${percentage}")
   }

})
 
Upload File to ZFS using fileRequestRefId and filePath
          
          
val fileRequestRefId = "uploadFiles" + System.currentTimeMillis().toString()

val filepath = "File(smallImagePath).absolutePath"

//Call uploadFile() by passing the fileRequestRefId and filePath.

//fileRequestRefId - reference id which is used as a tag to this api request

//filePath - Path of the file to be uploaded

ZCRMSDKUtil.uploadFile(fileRequestRefId, filepath, object:FileWithDataTransferTask<APIResponse,String>
{
    override fun onCompletion(response: APIResponse, zcrmEntity: String) {
        println("${response.responseJSON}")
    }

    override fun onFailure(exception: ZCRMException) {
        println("Throws Exception : $exception")
    }

    override fun onProgressUpdate(bytesWritten: Long, contentLength: Long, percentage: Double) {
        println("OnProgress Update : ${bytesWritten}+${contentLength}+${percentage}")
    }

})
 
Upload File to ZFS using fileRequestRefId and uri
          
          
//Call uploadFile() by passing the fileRequestRefId and uri

//fileRequestRefId - reference id which is used as a tag to this api request

//uri - uri of the file to be uploaded

ZCRMSDKUtil.uploadFile(fileRequestRefId, uri, object : FileWithDataTransferTask<APIResponse,String>
    {
        override fun onCompletion(response: APIResponse, zcrmEntity: String) {
            println("${response.responseJSON}")
        }
    
        override fun onFailure(exception: ZCRMException) {
            println("Throws Exception : $exception")
        }
    
        override fun onProgressUpdate(bytesWritten: Long, contentLength: Long, percentage: Double) {
            println("OnProgress Update : ${bytesWritten}+${contentLength}+${percentage}")
        }
    
    })