Final result:
My apologies for the mistake.
I set wrong value to Content-Range
in my http requests.
Example is here:
- Original file size: 5242880
- Chunk size: 2097152
- Required HTTP Request count: 3
Thus, the correct Content-Range
is following these:
- bytes 0-2097151/5242880
- bytes 2097152-4194303/5242880
- bytes 4194304-5242879/5242880
Thanks to your advice, i got to test with:
- cURL
- Postman
- Charles
- Node.js
- C#
- Swift
Second try with Postman:
I tried again a following API with Postman.
I use rst_basic_sample_project.rvt that provide by Autdesk.
The file is 5693440 bytes.
$ du -b rst_basic_sample_project.rvt
5693440 rst_basic_sample_project.rvt
I divided with the following command.
# Chunk size is 5 MB.
split -b 5242880 rst_basic_sample_project.rvt "temp/data-"
So, i got data-aa
and data-ab
.
Next, try to use PUT buckets/:bucketKey/objects/:objectName/resumable.
Send data-aa
to API. HTTP Request is here:
PUT /oss/v2/buckets/${MY-BUCKET-KEY}/objects/${MY-OBJECT-NAME}/resumable HTTP/1.1
Host: developer.api.autodesk.com
Authorization: Bearer ${MY-TOKEN}
Content-Range: bytes 1-5242880/5693440
session-id: j45e05
Content-Type: application/octet-stream
"<data-aa binary>"
I got HTTP 202. It's expected result.
And, send data-ab
to API. HTTP Request is here:
PUT /oss/v2/buckets/${MY-BUCKET-KEY}/objects/${MY-OBJECT-NAME}/resumable HTTP/1.1
Host: developer.api.autodesk.com
Authorization: Bearer ${MY-TOKEN}
Content-Range: bytes 5242880-5693440/5693440
Content-Type: application/stream
session-id: j45e05
Content-Type: application/octet-stream
"<data-ab binary>"
I got HTTP 416 Requested Range Not Satisfiable
.
It's unexpected result.
First try with cURL:
Please show me how to upload a large file.
I'm trying to upload a file larger than 100MB using the API below.
- PUT buckets/:bucketKey/objects/:objectName/resumable https://forge.autodesk.com/en/docs/data/v2/reference/http/buckets-:bucketKey-objects-:objectName-resumable-PUT/
First of all, i simply want to know the API response and verify. Therefore, I sent HTTP PUT Request with cURL.
- The large file is 157286400 bytes (Using command
dd if=/dev/random of=bigfile bs=1M count=150
) - Data chunk size is 5242880 bytes (Using command
split -b 5242880 bigfile "temp/data-"
)
cURL command is here:
curl \
-v \
-X PUT "https://developer.api.autodesk.com/oss/v2/buckets/${MY-BUCKET-KEY}/objects/${MY-OBJECT-NAME}/resumable" \
-H "Authorization:Bearer ${MY-TOKEN}" \
-H "Content-Length: 5242880" \
-H "Content-Type:text/plain; charset=UTF-8" \
-H "Content-Range:bytes 1-5242880/157286400 " \
-H "Session-Id:111111111" \
--data @temp/data-aa # One of the files created by splitting a large file with the split command.
# PUT /oss/v2/buckets/${MY-BUCKET-KEY}/objects/${MY-OBJECT-NAME}/resumable HTTP/1.1
# Host: developer.api.autodesk.com
# User-Agent: curl/7.69.0
# Accept: */*
# Authorization:Bearer ${MY-TOKEN}
# Content-Length: 5242880
# Content-Type:text/plain; charset=UTF-8
# Content-Range:bytes 1-5242880/157286400
# Session-Id:111111111
API response return HTTP/1.1 504 GATEWAY_TIMEOUT
.
How to upload a large file than 100MB via Data Management API on the Autodesk Forge?