in OSSSwiftDemo/OSSSwiftDemo/Classes/OSSRootViewController.swift [385:423]
func resumableUpload() -> Void {
var request = OSSResumableUploadRequest()
request.uploadingFileURL = Bundle.main.url(forResource: "wangwang", withExtension: "zip")!
request.bucketName = OSS_BUCKET_PRIVATE
request.deleteUploadIdOnCancelling = false;
request.objectKey = "wangwang(swift).zip"
let cacheDir = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.cachesDirectory, FileManager.SearchPathDomainMask.userDomainMask, true).first
request.recordDirectoryPath = cacheDir!
request.partSize = 102400;
request.uploadProgress = { (bytesSent: Int64, totalBytesSent: Int64, totalBytesExpectedToSend: Int64) -> Void in
print("bytesSent:\(bytesSent),totalBytesSent:\(totalBytesSent),totalBytesExpectedToSend:\(totalBytesExpectedToSend)");
if totalBytesSent > (totalBytesExpectedToSend / 2) {
request.cancel()
}
}
var task = mClient.resumableUpload(request)
task.continue({ (t) -> Any? in
print("Error: \(String(describing: t.error))")
return nil
}).waitUntilFinished()
request = OSSResumableUploadRequest()
request.uploadingFileURL = Bundle.main.url(forResource: "wangwang", withExtension: "zip")!
request.bucketName = OSS_BUCKET_PRIVATE
request.objectKey = "wangwang(swift).zip"
request.partSize = 102400;
request.deleteUploadIdOnCancelling = false;
request.recordDirectoryPath = cacheDir!
request.uploadProgress = { (bytesSent: Int64, totalBytesSent: Int64, totalBytesExpectedToSend: Int64) -> Void in
print("bytesSent:\(bytesSent),totalBytesSent:\(totalBytesSent),totalBytesExpectedToSend:\(totalBytesExpectedToSend)");
}
task = mClient.resumableUpload(request)
task.continue({ (t) -> Any? in
self.showResult(task: t)
return nil
}).waitUntilFinished()
}