Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#2,474 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
android, java, javascript
領域
mobile

調査の方向性

Share プラグインの SharePlugin.java と、issue に示されている ShareOptions API から始めます。現在の MIME 推測とフォールバック動作を、ファイルごとの MIME タイプまたはデフォルト MIME タイプに対して要求されているオプションと比較します。拡張子が認識されないファイルに対して、明示的に指定されたタイプを Android の共有で使用できるようになれば完了です。報告されている WhatsApp のケースも含みます。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Java
スター
687
フォーク
691
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ionic-team/capacitor-plugins のほかの issue

ionic-team/capacitor-plugins の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。