CreateMode.REPLACE not respected when missing permissions

オープン 初心者向け
#160 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
73/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
活発
技術スタック
android, kotlin
領域
mobile

調査の方向性

CreateMode.REPLACE と MediaStoreCompat のドキュメントまたは API ガイダンスを確認し、権限がない場合に示されている Android の例がどのように動作するかをレビューしてください。MediaStore が既存のユーザー作成ファイルを置き換えるのではなく、名前を変更したファイルを作成する場合があることを、関連する落とし穴と例の動作を含めて文書化してください。

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

説明

This is somewhat related to #159 but expresses itself in a different manner.

Assume you have a function to create some file. However this function tries to create a file that already exists, and was created with scoped storage or manually by the user, even if the app has granted the permissions of that folder. Then CreateMode.REPLACE is not respected. The code below creates a file named "hello (1).txt".

This is a limitation of using the MediaStore API, but I still thing this should be docummented as a pitfall of CreateMode.REPLACE or MediaStoreCompat.

fun testAlreadyCreated(context : Context) {
    val file = MediaStoreCompat.createDownload(
        context = context,
        file = FileDescription(
            name = "hello",
            "test",
            mimeType = "text/plain"
        ),
        mode = CreateMode.REPLACE
    )?.toStorageFile(context)

    println("file created with the name = ${file?.name}" )
    file?.openOutputStream()?.writer()?.use { writer ->
        writer.write("Hello World!")
        writer.flush()
    }
}
主要言語
Kotlin
スター
867
フォーク
103
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

anggrayudi/SimpleStorage のほかの issue

anggrayudi/SimpleStorage の issue をすべて見る

似ている issue

Kotlin の issue をもっと見る

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

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