@liviutudor the ton-upload script actually does do a multi-part resumable upload but it’s automatically determined based on the file size. If the upload file is > 8MB it will automatically switch to a multi-part upload.
The logic fork on file size is here:
Here’s the code that initiates a multi-part upload (POST request):
As you can see, the header’s specified on the initial multi-part request are:
- X-TON-Content-Type (correct MIME type)
- X-TON-Content-Length (file size)
- X-TON-Expires (can be up to 7 days)
- Content-Length (always 0 on the initial POST)
- Content-Type (same as X-TON-Content-Type)
The remaining chunks get sent in subsequent requests as follows (PUT request):
For the individual chunk requests, only Content-Type, Content-Length and Content-Range headers are set. In addition, the PUT request with each chunk must contain the location value returned from the initial POST where your multipart session was created.
If your initial POST to create a multi-part session returned a 403 or failed for any other reason, the subsequent PUT requests for each chunk will return a 400 due to that location not being valid. I believe the issue in your initial POST request is that content length is set to 325 and should be set to zero.
Also note that application/x-www-form-urlencoded is never allowed and will be treated as a bad request. Looking at your request trace, you aren’t setting this and you’re ok here but its a common pitfall worth pointing out.