Skip to main content

I have some big files to upload to Drive/Sharepoint via Graph. 

How do I model this scenario in Thinkwise?

Steps to Upload a Large File Using Resumable Upload Session

  1. Create an Upload Session Use the /drive/items/{parent-id}:/{filename}:/createUploadSession endpoint to initiate the upload process.

    Request:

    POST https://graph.microsoft.com/v1.0/me/drive/items/{parent-id}:/{filename}:/createUploadSession Authorization: Bearer <access_token> Content-Type: application/json

    Body (Optional):

    { "item": { "@microsoft.graph.conflictBehavior": "rename", "name": "your-backup-file.bak" } }

    Response: The response contains an uploadUrl that you use to upload the file in chunks.

    Example Response:

    { "uploadUrl": "https://upload.url.for.your.session", "expirationDateTime": "2024-11-16T23:59:00Z" }

  1. Upload the File in Chunks Divide your file into chunks and upload each chunk using a PUT request to the uploadUrl.

    Chunk Size:

    • Recommended size: 10 MB (10,485,760 bytes).
    • Maximum size: 60 MB (62,914,560 bytes).

    Request for Each Chunk:

    PUT {uploadUrl} Content-Range: bytes {start}-{end}/{total-size} Content-Type: application/octet-stream

    Body: The binary data for the chunk.

    Example Content-Range:

    • For the first 10 MB chunk of a 580 MB file:

      Content-Range: bytes 0-10485759/580000000

    Continue until all chunks are uploaded.

  1. Complete the Upload Once the final chunk is uploaded, the file is automatically saved in the specified location.

    If successful, the API responds with the metadata of the uploaded file, such as:

    { "id": "unique-file-id", "name": "your-backup-file.bak", "size": 580000000, "webUrl": "https://graph.microsoft.com/v1.0/me/drive/items/unique-file-id" }

Be the first to reply!

Reply