icloud media retrv'l ... speed up?

we are doing something like this to get photo data from photo kit (see code)

however, when the media is on iCloud, it seems like it is trying to pull the highest res possible (e.g. for RAW photos or ProRes vid maybe). which can take a lonnnng time if you are on a cellular net. this completely bogs down the app.

is there a recommended way to get a normal res media item from this (e.g. not pull the highest res from icloud?); either a standard jpeg or a lower res movie?

[phasset requestContentEditingInputWithOptions:options

                                         completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *infoin) {
  • Added note: in the Settings for iCloud under Optimize storage, it mentions: "If your phone is low on space, full resolution photos and videos are automatically replaced with smaller, device size versions. We want the smaller device size versions." Anyone know how to get these from photo kit to avoid the big icloud download delay?

Add a Comment

Replies

The API you point out should only be used for preparing to edit an asset. This api will always require the original content as that's what editing sessions require. If you want lower resolutions of assets to show in UI you should take a look at the PHImageManager and related apis. These allow you to specify attributes like the target size you are looking for, whether network downloading is allowed, etc.

https://developer.apple.com/documentation/photokit/phimagemanager?language=objc

  • ah ha, thanks

Add a Comment

another question has arisen on this issue. the PHImageManager seems to only return a UIImage. however, the noted API above requestContentEditingInputWithOptions works for live photos and videos also (and our code is using it for that) is there is there a similar fast replacement we can use for live photos and videos? e.g. to avoid the long download from icloud and just use local editions of these other media types? thanks again!

I guess another question would be, if we set networkAccessAllowed to NO would we get a reduced size (local to device) media or would we get nothing or error? (E.g. in our original requestContentEditingInputWithOptions call)

 PHContentEditingInputRequestOptions * options = [[PHContentEditingInputRequestOptions alloc] init];

                   options.networkAccessAllowed = YES;

doc doesnt mention this issue:

https://developer.apple.com/documentation/photokit/phcontenteditinginputrequestoptions?language=objc