plugins-workspace icon indicating copy to clipboard operation
plugins-workspace copied to clipboard

Plugin Request: Share Files or Data

Open ecmel opened this issue 1 year ago • 9 comments

Web Share API is not available for android https://developer.mozilla.org/en-US/docs/Web/API/Web_Share_API and shell open does not work with file paths on mobile.

We need a way to make the mobile app share files or data.

ecmel avatar Jun 13 '24 16:06 ecmel

Hi @ecmel , I would try to implement this

Here we only speak about sending data rigth, not be the target ?

The downside of Android's intent is the api can't be 1-1 to the web api, and the guest js should be the most platform agnostic I believe

PS: there is no way to ensure the share worked, there is no standard about that, some application respond when the handling of the file is ok, some other when the file is valid, some other only respond with errror when it's invalid... And most app never respond 😅🥹 (but accept without any issue the file)

flapili avatar Jul 10 '24 02:07 flapili

Hi @flapili thank you for your response, yes I am speaking about sending data not target. Specifically I need to share a pdf file stored in app data dir and view it in system's default pdf viewer or send by e-mail etc. For MacOS the shell open api works very well, for iOS web share api some what works but for android I could not find a way.

ecmel avatar Jul 10 '24 07:07 ecmel

I'll try to take a look, but I'm clueless about path, I only found example when the file is sent as bytes not path

What kind of spec / DX / final API would you like to have ?

EDIT: found https://developer.android.com/reference/android/content/ContentUris

flapili avatar Jul 10 '24 07:07 flapili

In fact https://beta.tauri.app/reference/javascript/shell/#open function works on desktop very well, on android I get the following error. This may be a purely device permission issue and may be easy to fix. Screenshot 2024-07-16 at 12 17 03

ecmel avatar Jul 16 '24 09:07 ecmel

@flapili While searching for a solution I bumped into https://stackoverflow.com/questions/42213316/how-to-share-file-in-android Not tried yet but can be a simple solution for file sharing.

ecmel avatar Jul 21 '24 08:07 ecmel

Also, the following capacitor plugins can be relevant:

https://github.com/ionic-team/capacitor-plugins/tree/main/share https://github.com/capacitor-community/file-opener

ecmel avatar Jul 25 '24 14:07 ecmel

I have made a plugin for viewing files on mobile similar to shell open on desktop: https://github.com/ecmel/tauri-plugin-view

ecmel avatar Nov 16 '24 03:11 ecmel

I have made a plugin for viewing files on mobile similar to shell open on desktop: https://github.com/ecmel/tauri-plugin-view

@ecmel Thank you for creating this plugin! 🙌 I’ve been struggling to find a solution for viewing files on mobile, and your plugin worked perfectly for my use case. It literally saved my app (https://apps.apple.com/in/app/simple-invoice-bill-maker/id6737187790) — couldn’t have shipped without it!

codewithmanishkumar avatar Nov 27 '24 06:11 codewithmanishkumar

I found another plugin that offers text sharing on both Android and iOS: https://github.com/buildyourwebapp/tauri-plugin-sharesheet

There is also a fork that adds file sharing and some tests: https://github.com/rittme/tauri-plugin-sharesheet

The code looks pretty simple. It would be nice if such a plugin could become an official part of plugins-workspace.

jgonera avatar May 14 '25 01:05 jgonera