Alexey Chekanov
Alexey Chekanov

Reputation: 1117

Saving CKAsset from Core Data

I have some data like pictures, stored in Core Data as binary data and marked as "Allows External Storage". I'd like to write this data to the CloudKit. Is it possible to get URLs for this data and pass it to CKAsset, or transform somehow this data to CKAsset without double writing this data to some temporary files? Thank you.

Upvotes: 3

Views: 535

Answers (1)

Tom Harrington
Tom Harrington

Reputation: 70946

Accessing external binary data directly is not supported and there's no API for it. Unofficially it's not hard to figure out what directory the files are stored in, but it's not useful because

  • Filenames are UUIDs, and there's no documented way to link a managed object to a UUID, so you don't know which file to use.
  • The option is to allow external storage, so there's no guarantee that an external file exists. Some instances may not use external storage.

I'm not sure what CKAsset requires but you'll have to look up the binary data via the managed object first.

Upvotes: 1

Related Questions