MediaLibrary.createAssetAsync - Created asset is completely different from original file
See original GitHub issueš Bug Report
Environment
iOS (Not tested on Android)
Steps to Reproduce
- Create a new asset from an existing file:
MediaLibrary.createAssetAsync(uri);
- Get asset info of newly created asset:
MediaLibrary.getAssetInfoAsync(asset);
FileSystem.getInfoAsync(asset.uri, { md5: true });
- Compare against original file info:
FileSystem.getInfoAsync(uri, {md5: true });
Expected Behavior
Original file is copied over as an asset, unmodified or at least has a way to determine if a file has already been turned into an asset.
Actual Behavior
Newly created asset is completely different than original file. MD5 hash, filename, and size no longer match as the file has been opaquely transformed for some reason. Thereās no way to compare if the original file actually exists as an asset because no asset properties match the original file properties.
It should also not create duplicate files. Currently you can pass the same uri into createAssetAsync
and it will create a duplicate asset with a new filename.
Reproducible Demo
Check the console output: https://snack.expo.io/@justindmyers/bold-beef-jerky
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
MediaLibrary - Expo Documentation
Saves the file at given localUri to the user's media library. Unlike createAssetAsync() , This method doesn't return created asset. On iOS 11+,...
Read more >React Native/Expo Media Library exception when saving large ...
createAssetAsync () functions to hang and eventually throw a generic exception Unable to save file to external storage . With smaller files IĀ ......
Read more >How to use the expo-media-library.MediaType function ... - Snyk
To help you get started, we've selected a few expo-media-library.MediaType examples, based on popular ways it is used in public projects.
Read more >How to use Camera from Custom Code in a Draftbit app
Complete Code Snippet. Create a custom camera component from expo-camera. The expo-camera library provides a React component that allows snapping pictures usingĀ ...
Read more >How to Save Files to a Device Folder using Expo and React ...
Save files to a device's internal storage so that it's publicly visible to other apps with one line of code.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Could you try to use
asset.localUri
instead ofasset.uri
inFileSystem.getInfoAsync
?I donāt have good news ā this is expected behavior. On iOS you can download an image from the internet, save it to photo library multiple times and youāll get them duplicated. Thatās how it works under the hood in the operating system and there is nothing we can do as far as I know.
This issue was closed because it has been inactive for 7 days since being marked as stale. Please open a new issue if you believe you are encountering a related problem.