-
Notifications
You must be signed in to change notification settings - Fork 671
Open
Labels
Description
Feature Request
Plugin
share
Description
The app I am working on has an uncommon file extension, and android.webkit.MimeTypeMap quite reasonably does not know what it should map to. Unfortunately, some apps (WhatsApp for instance) do not seem to respect sharing files of type */* and the file I wish to share is being discarded making a rather useless text-only share.
Platform(s)
Android
Preferred Solution
I would like some way to be able to include a more accurate filetype (in my case application/octet-stream is sufficient) when I call Share.share(...). This could be implemented as an optional object syntax in the files array of ShareOptions e.g.
Share.share({
...
files: [
{file: "file://location/", mimeType: "application/octet-stream"},
{file: "file://location/", mimeType: "application/octet-stream"},
]
}
Alternatives
- Allow the user to pass a custom MIME type map to the Share plugin prior to calling it.
- Incorporate a
defaultMimeTypeinShareOptionsthat is used wheneverandroid.webkit.MimeTypeMapis unable to determine the MIME type from the extension. - As a proof of concept I have manually changed the fallback MIME type in
SharePlugin.javain my build area to change it from*/*toapplication/octet-stream, though this is not a long-term solution. I.e. in the place where MIME types are inferred:
String type = getMimeType(file);
if (type == null || filesList.size() > 1) {
type = "application/octet-stream";
}
And this causes the share approach to work satisfactorily with WhatsApp.
Reactions are currently unavailable