Skip to main content
Version: 2.0.x

Upload and Retrieve the Temporary File - iOS

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

uploadBase64File()

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

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

  • You have to pass base64Data,token,fileName as parameter in uploadBase64File() function.

  • The function will return the corresponding url, which you can then use to retrieve the file.

  • If the upload fails, it will return nil.

func uploadFile() {
let base64Data: String = "<Your-base64-File>"
let token: String = "<Your-Token>"
let fileName: String = "name.jpeg" // Provide file name with extension

meeting.uploadBase64File(base64Data: base64Data, token: token, fileName: fileName) { url in
//checking for successful upload
guard let url = url else {
print("upload failed")
return
}
print("url: ", url)
}
}

fetchBase64File()

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

  • You have to pass the url which is returned by uploadBase64File() function, and the token as parameters to retrieve a file.

  • This method will return the image in the form of base64 String.

  • If the retrieval fails, it will return nil.

func fetchFile() {

let url: String = "<Your FileUrl>"; // Provide fileUrl which is returned by uploadBase64File()
let token: String = "<Your-Token>"

meeting.fetchBase64File(url: url, token: token) { base64Data in
//checking for successful retrieval
guard let base64Data = base64Data else {
print("retrieval failed")
return
}
print("base64: ", base64Data)
}
}
note

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

Got a Question? Ask us on discord