microsoftgraph / microsoftgraph/msgraph-sdk-java

File Corruption in SharePoint Upload via Microsoft Graph API

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

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

status:waiting-for-triage type:bug
主要言語
Java
スター
444
フォーク
154
平均マージ
18時間 28分
マージ済み PR(30日)
4

説明

Describe the bug

I am using the Microsoft Graph API 5.80.0 to upload files to SharePoint from a Java Spring Boot application. The upload works fine in normal conditions, but some files become corrupted while uploading & so unable to download from SharePoint.

Most of the upload files are smaller than 4 MB, so I am using the simple upload method (PUT request).
The upload process completes successfully (returns 200 OK with a valid file ID). When I receive the webhook for the same the file size is 0 & not able to open the file as the file is corrupted. It happens randomly for a few of the requests.

private fun uploadFile(document: DocumentUploadStream) {
    val timeMillis = System.currentTimeMillis()
    val buildDriveItemRequest : DriveItemRequestBuilder = microsoftGraphClient.drives("driveId").root().itemWithPath(document.path)

    
    if (document.size < 4 * 1024 * 1024) { 
        // Simple upload for small files
        val driveItem = retry {
            refreshToken { 
                buildDriveItemRequest.content().buildRequest()
                    .put(document.contentToStream.readAllBytes()) 
            }
        }
        logger.info { "Upload done ${document.path}, id: ${driveItem?.id}, time: ${(System.currentTimeMillis() - timeMillis)/1000}s" }
        document.id = driveItem?.id
    } else { 
        // Large files use upload sessions (this part is working fine)
    }
}

data class DocumentUploadStream(
        val path: DocumentPath,
        val contentToStream: InputStream,
        val size: Long
)
Expected behavior

The file should not get corrupted on upload.
Any insights or recommendations would be greatly appreciated!
Thanks

How to reproduce

With the attached snippet of code, it should be reproducible randomly.

SDK Version

5.80.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

調査の方向性

提供された uploadFile スニペットの simple-upload ブランチから始め、Microsoft Graph SDK 5.80.0 の呼び出しで document.contentToStream がどのように消費されるかを確認します。ソースサイズ、アップロード後の SharePoint のサイズ、webhook のタイミングを比較しながら断続的に発生するケースを再現します。信頼できる原因を特定し、検証済みの修正を確認できたら完了です。

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

評価

技術スタック
java, kotlin, spring-boot
領域
api, backend, cloud
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

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

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