How to store a large image in CloudKit?

I tried uploading the image to CloudKit and saving it as NSData , but with a relatively large image taken by the camera, I get this error:

 Error saving record <CKRecordID: 0x15998770; 04359DFA-8370-4000-9F53-5694FC53FA9C:(_defaultZone:__defaultOwner__)> to server: record too large id=04359DFA-8370-4000-9F53-5694FC53FA9C of type UserSetting 

What is the maximum size of data that can be stored in CloudKit ?

How to save large camera images in CloudKit ?

I tried with two images and I plan on their size.

 let d = UIImagePNGRepresentation(image) println("d.length: \(d.length)") 
  • d.length: 55482 <- works
  • d.length: 17614327 <- does not work
+5
source share
1 answer

You must store images as CKAsset. CKRecord has a size limit. No CKAsset (besides CloudKit storage limits). According to the documentation:

Use assets for discrete data files. If you want to associate images or other discrete files with a recording, use the CKAsset object for this. The total size of these records is limited to 1 MB, although the assets are not counting this limit.

You can create a CKAsset as follows:

 var File : CKAsset = CKAsset(fileURL: NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("image-not-available", ofType: "jpg")!)) 
+8
source

Source: https://habr.com/ru/post/1210544/


All Articles