Uploading files
Multiple file uploads
In order to understand the multiple file upload, please make sure you read Send a job uploading a file first.
What the API normally does when you upload a file is:
- Store the file
- Start processing the job with that file
- Stop accepting more file uploads
To upload multiple files to a job, you need to create a job just like in the first step in Send a job uploading a file, but this time with an addition of the process key.
By setting the process field to false, the API will not process the job, even if it receives a file upload.
This way, you are able to repeat the POST request with different file contents like it is explained in Send a job uploading a file.
Processing jobs
At this point, all the files that you wanted to upload should be uploaded. Now, the API needs to know that the job can be processed.
This is done by sending a PATCH
request to the job endpoint.
Send the process
key as false
and specifying your
job id in the url. Consider the following example.
After the request is sent, you will get a response similar to the following.
Note the status processing
.
{
"id": "9f7cc24d-239a-432f-aa6e-1a98aa24a34e",
"token": "xxxxxxx119c487e6f53df33c8d653aa0",
"type": "job",
"status": {
"code": "processing",
"info": "The file is currently being processed."
},
"errors": [],
"process": true,
... extra information ...
"server": "https://www5.api2convert.com/v2/dl/web2",
"spent": 0,
"created_at": "2017-08-16T17:06:11",
"modified_at": "2017-08-16T17:09:58"
}
Chunked Uploads
It is possible to do a chunked upload to our servers. To do this, simply post the chunks to the same URL as described in Send a job uploading a file.
To be able to do the upload in chunks, you have to send the following headers with every chunk:
x-oc-upload-uuid
- Put your unique, randomly generated identifier here. This can be any string, even a numeric index, but it has to be unique across the job.
Content-Range
- The content range of the current chunk in the following format:
start-end/total
- Example:
Content-Range:bytes 0-1048575/5230812
for the first 1MB chunk of an approximately 5MB file
- Example:
- The content range of the current chunk in the following format:
start-end/total