简体   繁体   中英

CloudKit - Share Files between Users via a URL

What is the easiest way to share files between users with CloudKit?

This framework ( https://github.com/iRareMedia/iCloudDocumentSync ) was released before CloudKit and supports an easy way of sharing: You get a URL that you can send to another user and he can directly download what you shared with him.

Is something like this (or even better) available with the new CloudKit?

You could solve this by creating a CKRecord that contains a CKAsset which is the file that you want to share. You would need a unique identifier for that CKRecord. You could use the recordId for this. Then setup deeplinking for your app. This seems to be a good tool for that: https://github.com/usebutton/ios-deeplink-sdk Then just create a deplink that includes that unique identifier. When you app is opened with such a link, then you can download the CKRecord and you will have the file in a CKAsset.

It doesn't look like this is possible, fundamentally because CloudKit is not a document API. Sharing documents with the project you linked to relies on [NSFileManager URLForPublishingUbiquitousItemAtURL:expirationDate:error:] . That method works for documents saved to the current iCloud account.

Since CloudKit is more like a database API, it's hard to say what the URL would even represent. A record? Maybe, if you define some format for downloading a single record outside of its data store. It might make more sense for CKAsset , but for now Apple hasn't added the capability.

Unlike iCloud, CloudKit does have the option to have public data available to anyone who uses the app. Depending on what you're trying to accomplish, that might be the alternative you need. Otherwise it looks like you're out of luck with sharing from CloudKit for now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM