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 theMeetingclass, you can upload your file to Videosdk's Temporary storage. -
The
uploadBase64File()function only works withbase64String. Therefore, it is necessary to convert your file intobase64String format. -
You have to pass
base64Data,token,fileNameas parameter inuploadBase64File()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.
- Swift
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 theMeetingclass, you can retrieve your file from Videosdk's Temporary storage. -
You have to pass the
urlwhich is returned byuploadBase64File()function, and thetokenas parameters to retrieve a file. -
This method will return the image in the form of
base64String. -
If the retrieval fails, it will return
nil.
- Swift
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)
}
}
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

