Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ios] No permission to access certain videos from MediaLibrary #8769

Closed
awinograd opened this issue Jun 10, 2020 · 4 comments
Closed

[ios] No permission to access certain videos from MediaLibrary #8769

awinograd opened this issue Jun 10, 2020 · 4 comments

Comments

@awinograd
Copy link
Contributor

awinograd commented Jun 10, 2020

馃悰 Bug Report

Summary of Issue (just a few sentences)

I'm using MediaLibrary.getAssetsAsync and MediaLibrary.getAssetInfoAsync to display a custom rendered media library picker. My assets render fine except for certain video assets (that I believe are backed up to iCloud rather than immediately available on the device).

If I try to call VideoThumbnails.getThumbnailAsync(asset.localUri) I get a "You don't have permission" error if the local uri is in /var/mobile/Media/PhotoData

not working: file:///var/mobile/Media/PhotoData/Metadata/DCIM/100APPLE/IMG_0005.medium.MP4

working: file:///var/mobile/Media/DCIM/100APPLE/IMG_0007.MOV

Environment - output of expo diagnostics & the platform(s) you're targeting

  Expo CLI 3.20.1 environment info:
    System:
      OS: macOS 10.15.5
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.14.0 - ~/.nodenv/versions/12.14.0/bin/node
      Yarn: 1.12.1 - ~/.yarn/bin/yarn
      npm: 6.13.4 - ~/.nodenv/versions/12.14.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    IDEs:
      Android Studio: 3.5 AI-191.8026.42.35.6010548
      Xcode: 11.5/11E608c - /usr/bin/xcodebuild

Reproducible Demo

https://snack.expo.io/@ouihealth/f2e403

Steps to Reproduce

  1. Have videos in iCloud, but not locally stored on device (I was able to create this situation by taking videos and then loading my iPad with large files until storage was low https://speed.hetzner.de/)
  2. Open snack
  3. See that files stored locally generate thumbnails but those from iCloud result in errors

Expected Behavior vs Actual Behavior

All localUris should be able to generate thumbnails without permission errors.

Notes

  • VideoThumbnails is only one example API, but I wasn't able to access the localUris with
@awinograd awinograd added the needs validation Issue needs to be validated label Jun 10, 2020
@byCedric
Copy link
Member

Hi @awinograd, thanks for the issue report! As always, it's well documented 馃憤 I think this is similar to issue #8541, right? To fetch the thumbnail of a remote video, e.g. iCloud, we need to download the asset first. Unfortunately, such an API to do that doesn't exist at the moment. But, we are definitely open to any PR making this possible.

As for the "You don't have permission", you could try making this accessible for Expo using the MediaLibrary.saveToLibraryAsync method. It might duplicate this but might work around this permission issue. If not, we probably have to find another way to get a thumbnail from remote storage like this.

Hope it helps!

@byCedric byCedric removed the needs validation Issue needs to be validated label Jun 12, 2020
@awinograd
Copy link
Contributor Author

@byCedric the issue may be well documented but my "github search foo" could use some improvement 馃槅 Yep it looks like the linked issue is the same root cause. Happy to close this out. I'll add some follow-up thoughts to that issue too.

@byCedric
Copy link
Member

Haha, no worries, you complimented the original issue with this 馃槃

@borstessi
Copy link

borstessi commented Sep 11, 2020

The same problem occurs when i call MediaLibrary.getAssetInfoAsync to get the LocalUri of the Asset, which triggers it's download at the same time. To then render a Video Component with the given localUri.

In my case the thumbnails are generated but some of the videos that are in iCloud wont be played.

The following Error occurs: {"error":{"localizedDescription":"The file couldn鈥檛 be opened because you don鈥檛 have permission to view it.","domain":"NSCocoaErrorDomain","localizedFailureReason":"You don鈥檛 have permission.","localizedRecoverySuggestion":"To view or change permissions, select the item in the Finder and choose File > Get Info.","code":257},"target":2295}

But not for every asset! Same as mentioned above. Only if the asset relates to following path:

"localUri": "file:///var/mobile/Media/PhotoData/Metadata/DCIM/121APPLE/IMG_1353.medium.MP4",

This is working: "file:///var/mobile/Media/DCIM/100APPLE/IMG_0007.MOV"

So how is the proper way to handle that? Without copying the same asset to the library?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants