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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactNativeBlobUtil.fs does not work if path contains 'content://' #365

Open
Aleksandriukas opened this issue May 28, 2024 · 2 comments
Open

Comments

@Aleksandriukas
Copy link

I'm encountering an issue with the fs.exists function in ReactNativeBlobUtil. The code I'm using is:
const fileExist = await ReactNativeBlobUtil.fs.exists(path ?? '');

When the file is located in the cache folder, the function works correctly and returns true if the file exists. However, when the file is not in the cache folder and the path contains 'content', such as content://com.android.providers.downloads.documents/document/msf%3A1000000018, the function always returns false.

Reproduction Steps:

Use a file path containing 'content' (e.g., content://com.android.providers.downloads.documents/document/msf%3A1000000018).
Call ReactNativeBlobUtil.fs.exists(path).
Observe that the function returns false, even if the file exists.
Expected Behavior:
The fs.exists function should correctly identify the existence of a file, even when the path includes 'content://'.

Additional Context:
I found a potential solution in another package that handles similar paths. The relevant implementation can be seen in the react-native-file-viewer repository:
solution(see line 50).

Proposed Solution:
Could you integrate a similar approach to handle 'content://' paths in your library? This would greatly enhance the functionality and reliability of fs.exists and similar methods.

Environment:

React Native Version: 0.73.6
ReactNativeBlobUtil Version: 0.19.9
Platform: Android
Thank you for your attention to this issue.

@Aleksandriukas Aleksandriukas changed the title ReactNativeBlobUtil.fs does not working if path contains 'content://' ReactNativeBlobUtil.fs does not work if path contains 'content://' May 28, 2024
@RonRadtke
Copy link
Owner

Hi,
thank you for the report.
We got quite a bunch of these cases fixed already: https://github.com/RonRadtke/react-native-blob-util/pull/341/files
But there are still some missing. Hope I can addresse them in the next release. Otherwise, If you're willing to help out with a PR. Would appreciate it very much!

@whispergong
Copy link

Same question. ReactNativeBlobUtil.fs.stat('content://xxx') will throw error [Error: failed to stat path null because it does not exist or it is not a folder]

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

No branches or pull requests

3 participants