Skip to main content
swift

Downloading Files

Downloading file content and accessing files.

Downloading a file from the Store and saving it by chunk (defined by size var) to Data():

var fileId = "FILE_ID"

guard let privMXEndpoint = endpointContainer.getEndpoint(nil) else {return}
if let api = privMXEndpoint.storeApi{
guard let size = try? api.getFile(fileId).size else {return}
guard let handle = try? api.openFile(fileId) else {return}
guard let data = try? api.readFromFile(withHandle: handle,
length: size) else {return}
_ = try? api.closeFile(withHandle: handle)
}