-
Notifications
You must be signed in to change notification settings - Fork 935
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
Does open with url: "file://<file_path>" work on Android? #629
Comments
Android share with file path should work. |
hey! testing on a real device:
if you need any other information don't hesitate to ask. For now i'm using the fallback by reading the file with |
@tststs great, thanks for your reply. |
any updates on this ? |
As far as I remember, sharing using file path is working fine. |
The example given there doesn't use file path, rather it uses data URLs with base64 encoded strings which doesn't have any issue. The only problem in this scenario is that url with path like "file://<file_path>" doesn't work. (NB: It works fine on ios) |
@jgcmarins hey, I faced something same, But when URL be like this So I'm forced to use the first file URL for other functionality and want to share it in this package, any idea about this? |
Hi 👋 I also have this issue, when sharing file using local path - other applications do not receive it.
I have created reproducible repo - https://github.com/olessavluk/sharebug
@jgcmarins any chance you could take a look? |
I've got the same issue with Samsung galaxy s9+, android 10. |
I have the same issue. Is there anybody solved the issue? I have text file and trying to share it with path like file:///data/user/0/com.myapp/files/my_file.txt but not working in (just) android |
I met the same issue on Android. we can't share with local file ""/data/user/0/com.lmaalam_admin/cache/Bill197994929333884192053.pdf"", we have to convert it to base 64. |
Thanks for the idea. I will check and share the result soon. |
Hi again. |
Hey @taduyde would you mind helping us testing that? 😄 |
It depends on where the file(s) are. If the file is on secondary storage like a sd card then it should work. For more information https://developer.android.com/reference/androidx/core/content/FileProvider there is different configs on android to enable "access" to different locations. But like @MateusAndrade said would be great if you could help us test it, it might be that we need to add more configuration to handle different scenarios/usecases. |
Hi @nirre7, @MateusAndrade, I already tested this pull request, but that pull request not help we resolve this issue with local file as here: /data/user/0/com.lmaalam_admin/cache/Bill197994929333884192053.pdf |
The PR fixes secondary storage for example sd cards, i.e not "local files". Im guessing (!) that the config your scenario needs is (which isn't setup in this lib, yet): https://developer.android.com/reference/androidx/core/content/FileProvider#SpecifyFiles |
@taduyde probably you need to transform your file on a base64 before sharing that. There are been some problems when passing I think this can help you: https://github.com/react-native-community/react-native-share#share-remote-pdf-file-with-gmail--whatsapp-ios |
Converting file to base64 before share solved my issue. Thanks! |
I have a local Image that needs to be shared. For ex in My react native project, I have a Image named Resources/1.png I want to share this Image. How can I achieve it? |
I have tried converting it to base64 using fetch blob but I'm seeing an error saying that the file or directory doesn't exist. Cannot share files on Android only. iOS is working fine. below is my original code before converting it to base64. This code is sharing correctly with ios but not with android. In android, I see `shareBill = async (title: string) => {
};` |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and i will leave this open |
I try to share a PDF file from the file system but it just doesn't work.
Also the docs are a bit unclear about if it's even possible to do this.
As in the docs for url:
URL you want to share (only support base64 string in iOS & Android ).
Does this mean only sharing a string is possible like:
url: "data:<data_type>/<file_extension>;base64,<base64_data>"
is possible? because scrolling down a bit it is stated that you can directly pass a file by usingfile://...
My options:
const options = {"filename": "test.pdf", "url": "file:///data/user/0/com.x.x/files/6cfe208c-1b45-4fac-af0f-aadb7e678a6b.pdf"}
Edit:
There are no errors. It resolves with success
Thanks in advance!
The text was updated successfully, but these errors were encountered: