[iOS] fileName is not the same as actual file name?
See original GitHub issueDescription
When I pick a photo from the Library, the response.fileName is not the same as the file name in response.uri. When I take a photo, there is no response.fileName at all. I have storageOptions enabled, as well as storageOptions.waitUntilSaved.
I can’t use response.uri to save the photo to local storage, because of this reason: Link
So I use this to return the actual file name:
let source = response.uri;
if (Platform.OS === 'ios') {
var subsource = source.substr(source.length - 40)
}
Then, I use react-native-fs to generate a dynamic uri to the file.
Example response object (this is when I pick from Library)
fileName:"IMG_0637.JPG"
fileSize:3016009
height:1500
isVertical:false
latitude:52.34070833333333
longitude:4.676461666666667
origURL:"assets-library://asset/asset.JPG?id=7DC370EF-5937-4AF6-A6E8-E8016D348568&ext=JPG"
timestamp:"2017-04-23T12:21:45Z"
uri:"file:///var/mobile/Containers/Data/Application/A7F68ABA-DD58-4123-ACFD-AF1596A3EE62/Documents/AD69F6C9-4E1F-45C1-BEC9-06FA1180A29A.jpg"
width:2000
Solution
Something like response.uriFileName that matches the file name in uri would be ideal.
Additional Information
- React Native version: 0.43.3
- React Native Image Picker version: 0.26.3
- Platform: iOS
- Development Operating System: macOS
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
[iOS] fileName is not the same as actual file name? #576
Description When I pick a photo from the Library, the response.fileName is not the same as the file name in response.uri.
Read more >Original file names of pictures changed b… - Apple Community
Starting to use Photos and iCloud Photo Library more extensively I now noticed that exported originals seem to have altered filesnames.
Read more >What characters are allowed in a iOS file name?
iOS is UNIX based and as such I suppose it supports almost any characters in filenames. UNIX allows white spaces, <, >, |,...
Read more >Solved: Saving files from iPhone browser changes name to "...
Clicking this option asks me for the location and the name of the file, but the name used to be inherited from the...
Read more >Path.GetFileName Method (System.IO) - Microsoft Learn
Returns the file name and extension of a file path that is represented by a ... so the behavior of the GetFileName method...
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 FreeTop 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
Top GitHub Comments
I have the same issue on iOS (Android all good), when taking from Library, with
fileName returned is still like :
IMG_0002.jpg
and the uri has a filename likeDFE43C-C0C3-4534-B3E0-C895BA7DD5A1.jpg
Both
storageOptions.cameraRoll
ANDstorageOptions.waitUntilSave
need to be true in order for captured media to have fileName and timestamp.This is mentioned in #394 and I’ve submitted #658 to update the README.