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
-
Create an Upload Session Use the
/drive/items/{parent-id}:/{filename}:/createUploadSessionendpoint 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/jsonBody (Optional):
{ "item": { "@microsoft.graph.conflictBehavior": "rename", "name": "your-backup-file.bak" } }Response: The response contains an
uploadUrlthat you use to upload the file in chunks.Example Response:
{ "uploadUrl": "https://upload.url.for.your.session", "expirationDateTime": "2024-11-16T23:59:00Z" }
-
Upload the File in Chunks Divide your file into chunks and upload each chunk using a
PUTrequest to theuploadUrl.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-streamBody: 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.
-
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" }
