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.

POST /jobs HTTP/1.1
Host: api2.online-convert.com
x-oc-api-key: <your API key here>
Content-Type: application/json
Cache-Control: no-cache

{
    "conversion": [{
        "category": "image",
        "target": "png"
    }],
    "process": false
}
curl -X POST \
  https://api2.online-convert.com/jobs \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'x-oc-api-key: <your API key here>' \
  -d '{
    "conversion": [{
        "category": "image",
        "target": "png"
    }],
    "process": false
}'

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.online-convert.com/dl/web2",
    "spent": 0,
    "created_at": "2017-08-16T17:06:11",
    "modified_at": "2017-08-16T17:09:58"
}
PATCH /jobs/9f7cc24d-239a-432f-aa6e-1a98aa24a34e HTTP/1.1
Host: api2.online-convert.com
x-oc-api-key: <your API key here>
Content-Type: application/json
Cache-Control: no-cache

{
    "process": true
}
curl -X PATCH \
  https://api2.online-convert.com/jobs/9f7cc24d-239a-432f-aa6e-1a98aa24a34e \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'x-oc-api-key: <your API key here>' \
  -d '{
    "process": true
}'

results matching ""

    No results matching ""