microsoftgraph / microsoftgraph/msgraph-sdk-java
File Corruption in SharePoint Upload via Microsoft Graph API
Personne n'a encore pris cette issue.
- Langage dominant
- Java
- Étoiles
- 444
- Forks
- 154
- Merge moyen
- 18 h 28 min
- PR mergées (30 j)
- 4
Description
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_
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par la branche simple-upload dans l’extrait uploadFile fourni et examinez comment document.contentToStream est consommé par l’appel au Microsoft Graph SDK 5.80.0. Reproduisez le cas intermittent tout en comparant la taille de la source, la taille du fichier téléversé dans SharePoint et le moment du webhook ; le travail est terminé lorsqu’une cause fiable a été identifiée et qu’une correction vérifiée a été trouvée.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- java, kotlin, spring-boot
- Domaine
- api, backend, cloud
- Type d'issue
- Bug
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100