Cloud Kit - Synching image

I'm currently sharing data between devices using core data and cloud kit.

Currently I have a "Picture" entity which stores the filename, the date it was added and a relation to another entity.

The details in core data successfully syncs, how would I go about syncing the image file. The file is saved in the documents folder and I can get its file path using

let imagePath = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString).appendingPathComponent(imageName)

Research seems to show I need to use CKAsset to upload/download the file but how do I go about doing this?

You can initialize a CKAsset with a file URL and assign it to a CKRecord:
Code Block swift
let record = CKRecord(...)
let asset = CKAsset(fileURL: pathToYourImageFile)
record["image"] = asset



https://developer.apple.com/documentation/cloudkit/ckasset/1514990-init
How would I get the records when core data deals with it behind the scenes?
@Desbrina did you ever find an answer to this?
Cloud Kit - Synching image
 
 
Q