microsoftgraph / microsoftgraph/msgraph-sdk-java
File Corruption in SharePoint Upload via Microsoft Graph API
還沒有人認領這個 Issue。
- 主要語言
- Java
- 星號
- 444
- 分支
- 154
- 平均合併
- 18 小時 28 分鐘
- 30 天內合併 PR
- 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_
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 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
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100