react-native-documents / document-picker

Document Picker for React Native

Home Page:https://react-native-documents.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[iOS] Cannot pick audio files with spaces in the file name

DanC5 opened this issue · comments

Bug report

I'm using your dependency to pick audio files and have noticed that the picker always fails if the audio file has a space in its name.

For example, a file named voicemail-1.m4a will succeed, but voicemail 1.m4a will fail.

Let me know if you think there's a way around this. Thanks for the product, otherwise it works really great for my app's needs!

library version: 8.1.3

iOS: reproduced on 13 and 16

Hello and thanks for reporting,
I cannot reproduce this. When you say "fails", what does that mean? Is there an stack trace that you can share? What file can you reproduce this with?
Please share code as well
Thank you 🙂

Hey @vonovak, thanks for looking into this one. When I say fails, I mean the picker just closes without selecting a file if the filename has spaces in it. I've tried this with numerous files and the picker fails to grab each one whenever I add a space. I have Document.pickSingle wrapped in a try/catch block and there also isn't a caught error either.

Fortunately this isn't a very big deal for my use case anymore because I've since implemented an iOS Share Extension target and that's now the optimal way of getting audio files into the app.

@DanC5 thanks, that's weird. Did you reproduce on device or simulator?

@vonovak it happens on both simulator and device. I just now tested it on my latest TestFlight build. I successfully upload an audio file with no spaces in the name, renamed the file to have a space, retry the newly name file, and it wasn't picked successfully.

@DanC5 thanks. Do you have a minimal reproducible example? Are you sure the problem is in the picker and not the file upload? (Please share code to show that.)

Thank you

@vonovak here's the function I'm calling to grab the audio file. The app is quite large at this point so I don't have a small, isolated example, but this is the only code running at the time of file picking. The catch block doesn't grab an error for not being able to process the files with spaces.

Screen Shot 2023-01-25 at 1 04 30 PM

hello, did you rule out that the problem is in RNFS.readFile?

I tend to believe it's there. Can you try the decodeURIComponent advice documented here? https://github.com/rnmods/react-native-document-picker#uri

thank you

@vonovak that worked! Thanks for pointing that out, much appreciated. I'm closing the issue, thanks.