Share feature: Ability to specify the mime type for Android files
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- android, java, javascript
- Domain
- mobile
Research direction
Start with the Share plugin's SharePlugin.java and the ShareOptions API shown in the issue. Compare the current MIME inference and fallback behavior with the requested per-file MIME type or default MIME type options. Done means Android sharing can use an explicitly supplied type for files whose extensions are not recognized, including the reported WhatsApp case.
Written by the indexing model from the issue text.
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.
- Dominant language
- Java
- Stars
- 682
- Forks
- 689
- Avg merge
- 6d 20h
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ionic-team/capacitor-plugins
-
[@capacitor/app] iOS: 'Expression implicitly coerced from String? to Any' warning in getAppLanguageOpentriage
Difficulty 1/5 Under an hour Newbie friendliness 88/100
ionic-team/capacitor-plugins#2604 ·
-
platform: android
Difficulty 3/5 1-2 days Newbie friendliness 78/100
ionic-team/capacitor-plugins#2605 ·
-
platform: ios
Difficulty 4/5 3-5 days Newbie friendliness 58/100
ionic-team/capacitor-plugins#2603 · 1 comment ·
-
platform: android
Difficulty 3/5 1-2 days Newbie friendliness 76/100
ionic-team/capacitor-plugins#2599 ·
-
platform: ios
Difficulty 3/5 1-2 days Newbie friendliness 68/100
ionic-team/capacitor-plugins#2595 · 2 reactions ·
All issues in ionic-team/capacitor-plugins
Similar issues
-
1.0.0-rc2
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
wso2/dpdp-accelerator#377 ·
Maintainers usually reply within 1 day
-
area/dependencies backport/26.4 kind/cve severity/high source/scan-dependencies status/triage
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 2 days
-
(primitive-collections-base) Use `NumberInput` to parse numeric map keys, as `jackson-databind` doesOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
FasterXML/jackson-datatypes-collections#270 ·
Maintainers usually reply within 1 day
-
type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day