Share via

Microsoft graph resumable upload api creates corrupt files in sharepoint

Richa Singh 1 Reputation point
2022-03-01T13:23:37.02+00:00

I am trying to upload files to SharePoint by creating upload session and then uploading bytes in chunks on the upload url. After completion when I try to open the file in SharePoint, it doesn't open and shows error. I am able to download the file though, which appears to be corrupted and has some missing content
There is no error response in the api calls, everything gets completed with no issues but for some reason the uploaded file is getting corrupted no matter what I try. I am using Postman for making the api calls. Anybody has any idea about this?
Also, if I use the same api but do it one shot rather than chunks the file gets uploaded without any corruption.

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Graph

3 answers

Sort by: Most helpful
  1. Srinivasa Rao Darna 6,851 Reputation points Microsoft External Staff
    2022-03-14T17:08:09.127+00:00

    Hi @Richa Singh ,

    Looks like you are uploading a very small file, uploading a very small chunks of data have errors while committing the file .

    Best practices-createuploadsession Use resumable file transfers for files larger than 10 MiB (10,485,760 bytes).
    For files smaller than 4MB, please make use of simple upload API, alternatively use upload session pass the entire content-ranges in single API call as the upload session can accept a maximum of 60MiB in API request.

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Was this answer helpful?


  2. Zehui Yao_MSFT 5,881 Reputation points
    2022-03-04T08:20:06.377+00:00

    Hi @Richa Singh ,

    I had a test to upload a .docx file with graph API, and the .docx file worked on my end. You could try to upload file using uploadurl like the below:

    Body:
    180038-image.png

    Header:
    180028-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


  3. Richa Singh 1 Reputation point
    2022-03-02T06:06:53.483+00:00

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.