i am unable to decide on what would be the best possible way to go ahead with the task of
Having 50 large video files with 50 large images corresponding to those files and some related text prepopulated in iCloud so that when the user downloads the app , they have some videos already installed to watch and not have to start from scratch…
I am aware of how to upload text to iCloud using some code as below , but I do. not know how will I proceed with large media files, where will I store them , how will I point to them ?
If a user wants to play those videos, will those videos need to be downloaded to the user device ? Will this not increase the size of app significantly ? How can I avoid this ?
All in all I am totally lost as to how to deal with large size files, how to prepopulate my app with some of these files and how to add more files in future ,
Can any one please guide and point me to a plan of action I can take in this regard ...
The code I have to be able to prepare and upload some data to iCloud , but I do not know how to use them when using large media files, where will I store those files etc
func prepareCloudRecords(owner: String) -> [CKRecord] {
let parentName = objectID.uriRepresentation().absoluteString
let parentID = CKRecord.ID(recordName: parentName)
let parent = CKRecord(recordType: "Project", recordID: parentID)
parent["title"] = projectTitle
parent["detail"] = projectDetail
parent["owner"] = owner
parent["closed"] = closed
var records = projectItemsDefaultSorted.map { item -> CKRecord in
let childName = item.objectID.uriRepresentation().absoluteString
let childID = CKRecord.ID(recordName: childName)
let child = CKRecord(recordType: "Item", recordID: childID)
child["title"] = item.itemTitle
child["detail"] = item.itemDetail
child["completed"] = item.completed
child["project"] = CKRecord.Reference(recordID: parentID, action: .deleteSelf)
return child
}
records.append(parent)
return records
}
Then use it to upload to server on button click like so making a function, thanks
func uploadToCloud() {
if let username = username {
let records = project.prepareCloudRecords(owner: username)
let operation = CKModifyRecordsOperation(recordsToSave: records, recordIDsToDelete: nil)
operation.savePolicy = .allKeys
operation.modifyRecordsCompletionBlock = { _, _, error in
updateCloudStatus()
}
cloudStatus = .checking
CKContainer.default().publicCloudDatabase.add(operation)
} else {
showingSignIn = true
}
}