Is there a way to cancel a CloudKit save or upload operation that's in progress?
This isn't a time-out situation. I notice videos take some time to upload and the user might decide to dismiss the vc. I would like to cancel the current upload if they do that.
let database = CKContainer.default().publicCloudDatabase
var operation: CKModifyRecordsOperation?
func save(videoURL: URL) {
let record = CKRecord(recordType: "MyType")
let fileURL = URL(fileURLWithPath: videoURL.path)
let asset = CKAsset(fileURL: fileURL)
record["videoAsset"] = asset
database.save(record) { (record, err) in
}
// or
operation = CKModifyRecordsOperation(recordsToSave: [record], recordIDsToDelete: nil)
operation?.savePolicy = .allKeys
operation?.modifyRecordsCompletionBlock = { (savedRecordIDs, deletedRecordsIDs, error) in
}
database.add(operation!)
}