Graph Api Chunked uploads RRS feed

  • Question

  • Since graph API allows chunked uploads why cant we create multiple threads and uploads different sections of the file. 

    <style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000} span.s1 {font-variant-ligatures: no-common-ligatures} </style>

    {"error":{"code":"invalidRange","message":"The uploaded fragment is not contiguous with the last one.","innererror":{"code":"fragmentOutOfOrder"}}}

    I get this error. But Is there a way to upload a file in chunks but choosing which segments to send. 

    So thread (1) can send 0-9 and thread (2)to sends  10-19. Currently if thread 2 sends this I get the above error. 


    Monday, August 28, 2017 4:30 AM

All replies

  • No, unfortunately that is not allowed/supported.  The documentation explicitly states the following (See here).

    "The fragments of the file must be uploaded sequentially in order. Uploading fragments out of order will result in an error." 

    So while that doesn't explicitly prevent you from using multiple threads, it would prevent you from having those threads upload parts of the same file at the same time.  Therefore, one alternative would be to instead upload multiple files at the same time.  While I have not tried it, I do not see any documentation that says you cannot have multiple UploadSessions open at the same time.

    However, be warned about and handle any throttling errors.  Some documentation is here.  It makes the following statements:

    "To recover from receiving a 429 or 503 response code, try again after waiting for the duration specified in the Retry-After field in the response header. If throttling persists, the Retry-After value may become longer over time, allowing the system to recover. Apps that do not honor the retry after duration before calling back will be blocked due to abusive calling patterns."

    "When waiting for 429 or 503 recovery you should ensure that you pause all further requests you are making to the service. This is especially important in multi-threaded scenarios. Making additional calls while receiving throttle responses will extend the time it takes for your app to become unthrottled."

    What that means to me is, while making a multi-threaded application to upload files isn't very difficult, coordinating the threads to have them all stop and wait whenever one receives an error due to throttling, can make the code a bit more complex.  Therefore, I have opted for just single threaded for the upload process.

    Saturday, October 26, 2019 5:45 PM