How to improve performance on file uploading to Sharepoint library via Graph API?

Alec Tang 0 Reputation points
2024-04-19T07:27:10.8533333+00:00

We have a program that utilises the graph API to upload a file to Sharepoint library. The issue is this runs with random latency. Sometimes it's a few secs, sometimes it's a few mins and sometimes it's 20 mins plus. Is there anything that could improve the performance?

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,665 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Haoyan Xue_MSFT 19,711 Reputation points Microsoft Vendor
    2024-04-22T06:58:53.8266667+00:00

    Hi @Alec Tang ,

    Thank you for posting in this community.

    This is because the file upload limit is set in the service and cannot be changed. When uploading files larger than 250 MB, use file chunking. This approach breaks the file into smaller chunks and uploads them sequentially. The operation in the Graph API provides an upload URL containing a session identifier. You can then use requests to upload chunks to this URL. Ensure that each chunk starts with the range specified in the “nextExpectedRanges” value from the previous response. /createUploadSessionPUTUse a chunk size divisible by 320 KiB (327,680 bytes) for efficient handling1.

    Reference:https://learn.microsoft.com/en-us/answers/questions/1574811/what-is-the-actual-size-limit-for-uploading-files

    Experiment with different chunk sizes to find the optimal balance between performance and reliability. Smaller chunks may reduce latency but increase the number of requests, while larger chunks may improve efficiency but increase the risk of failure.


    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.