Skip to main content
Version: 0.1.x

Upload and Retrieve the Temporary File - Android

This guide demonstrates how to upload and retrieve files from VideoSDK's temporary file storage system.

uploadBase64File()

  • By using the uploadBase64File() method of the Meeting class, you can upload your file to Videosdk's Temporary storage.

  • The uploadBase64File() method only works with base64. Therefore, it is necessary to convert your file into base64 format.

  • You have to pass base64Data,token,fileName and implementation of TaskCompletionListener as parameter in uploadBase64File() method.

  • When the upload is complete, the onComplete() method of TaskCompletionListener will provide the corresponding fileUrl, which can be used to retrieve the uploaded file.

  • If an error occurs during the upload process, the onError() method of TaskCompletionListener will provide the error details.

private fun uploadFile() {
val base64Data = "<Your File's base64>" // Convert your file to base64 and pass here
val token = "<VIDEOSDK_TOKEN>"
val fileName = "myImage.jpeg" // Provide name with extension here
meeting!!.uploadBase64File(
base64Data,
token,
fileName,
object : TaskCompletionListener<String?, String?> {
override fun onComplete(data: String?) {
Log.d("VideoSDK", "Uploaded file url: $data")
}

override fun onError(error: String?) {
Log.d("VideoSDK", "Error in upload file: $error")
}
}
)
}

fetchBase64File()

  • By using the fetchBase64File() method of the Meeting class, you can retrieve your file from Videosdk's Temporary storage.

  • To retrieve a file, you need to pass the fileUrl (which is returned by the uploadBase64File() method), the token, and an implementation of the TaskCompletionListener as parameters.

  • When the fetch operation is complete, the onComplete() method of TaskCompletionListener will provide the file in base64 format.

  • If an error occurs during the fetch operation, the onError() method of TaskCompletionListener will provide the error details.

private fun fetchFile() {
val url = "<Your FileUrl>" // Provide fileUrl which is returned by uploadBase64File()
val token = "<VIDEOSDK_TOKEN>"
meeting.fetchBase64File(url, token, object : TaskCompletionListener<String?, String?> {
override fun onComplete(data: String?) {
Log.d("VideoSDK", "Fetched file in base64:$data")
}

override fun onError(error: String?) {
Log.d("VideoSDK", "Error in fetch file: $error")
}
})
}
note

The file stored in the system will be automatically deleted once the current room/meeting comes to an end.

API Reference

The API references for all the methods and events utilised in this guide are provided below.

Got a Question? Ask us on discord