IOS – access iCloud Drive files from non-apple device

authenticationauthorizationicloudios

I have an application that stores its files on iCloud Drive for synchronization. I'd like to write a cloud service that can also access the files.

For example, if I record a video on my app, I'd like to ask my service to download the file, and send it to a transcoding service, or something.

From the device, can I create an authenticated URL to the file? Alternatively, can I create a temporary token to send to the server, so that it can access the file? Then, when transcoding is complete, can I write back to the iCloud Drive?

I'm mostly trying to avoid uploading the entire file from the device to the server, because the files might be quite large.

I'm also trying to use iCloud Drive to support the seamless file sync between device and mac laptop without having to explicitly authenticate – that type of thing isn't supported by google drive, or dropbox, correct?

Thanks very much in advance, I appreciate any help at all!

Best Answer

CloudKit

Apple offers CloudKit, which achieves something very similar to what you are describing.

If you're able to write an application both for your Mac and iOS device, you can sync data and files across devices relatively easily. For example, CloudKit allows you to store files and data in a free database, process it however you want in your apps, then re-upload it to the database. All of this happens without any explicit authentication.

The CloudKit framework provides interfaces for moving data between your app and your iCloud containers. You use CloudKit to take your app’s existing data and store it in the cloud so that the user can access it on multiple devices. You can also store data in a public area where all users can access it.

CloudKit | Apple Developer Documentation

Keep in mind that while CloudKit itself free and easy to use, there is a caveat; You have to have a paid Developer account, which costs $99 a year.

I would highly recommend you look into CloudKit and check out Apple's (outdated) CloudKit Quick Start guide to get a feel for how programming for it actually looks.

Access from Non-Apple Platforms

While CloudKit works best when used on an Apple device, it is certainly possible to interact with a CloudKit container with more platform agnostic methods.

The best solution may be to use CloudKit web services. This allows you to use either more traditional HTTP methods or JavaScript to interact with CloudKit data.

The part of CloudKit web services that has more up to date documentation is CloudKit JS, a JavaScript API for CloudKit.

Keep in mind that with either of these options, Apple says that, “You must have an existing CloudKit app and enable web services.” Details on how to setup CloudKit web service are in the linked CloudKit JS guide

Related Question