Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Share feature: Ability to specify the mime type for Android files

Open
#2,474 0 comments 0 reactions 0 assignees View on GitHub

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
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

platform: android

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 defaultMimeType in ShareOptions that is used whenever android.webkit.MimeTypeMap is unable to determine the MIME type from the extension.
  • As a proof of concept I have manually changed the fallback MIME type in SharePlugin.java in my build area to change it from */* to application/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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ionic-team/capacitor-plugins

All issues in ionic-team/capacitor-plugins

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.