File upload
CCA supports two ways of uploading an image, (1) a "direct" upload, i.e. all the bytes are uploaded using an AWS S3 pre-signed URL created by CCA and (2) a more "client oriented" upload that make use of tus (which among other things enables "resumable uploads") to upload files. The examples in the documentation uses cURL
to show how the API works. You can optionally specify a filename (shown in 1.2).
Upload file - direct mode
Upload the bytes of the file at once (in one request).
1: Create upload
Initiate direct upload.
Request
Response
Note the uploadId
in the response, this id is used in requests for getting status, creating document for file etc.
1.2: Create upload with filename
You can optionally add a filename to the request, which later will be used when a default naviga document is created (which is produced and available as an artifact).
Request
2: Upload file
Use the pre-signed upload URL and PUT to upload the bytes.
Request
Response
3. Get Status for upload
Note that before you can start polling for status, the actual file upload (see previous request) must have finished (polling for status has to do with the processing of the uploaded file).
In order to know when the processing of the uploaded file has been done, you need to poll CCA for status.
Request
Response
Until CCA is done processing the upload, the response would be:
When the file has been successfully uploaded, CCA will respond with:
As part of the response, CCA has created a manifest
for the uploaded file including:
uuid
- The v5 uuid to use when creating a document corresponding with the file (see below)hashedFilename
- The hashed name for the fileuri
- The uri for the file (used to calculate the uuid)contentClass
- Type of fileartifacts
- These are the different artifacts created as part of the uploading of the file
If there was an error uploading the file, CCA will respond with "status": "ERROR"
and an error message.
4. Get artifact (optional)
The artifacts described in the manifest
can now be fetched if desired as described below.
Request
Response
Note! The response in content
is base64 encoded.
5. Create file document
The file has now been uploaded. Next step is to create a NavigaDoc document with the metadata for the file. CCA has created, as part of the artifacts in the manifest, a NavigaDoc document including the metadata that has been extracted from the binary. The NavigaDoc document can be used by downloading the artifact with type navigadoc
. This document can then be uploaded to CCA (either as-is or updated with own data if necessary).
The request and response for creating a document is described in the "Documents" part of the API documentation.
Upload file - patch mode
Upload the bytes of the file in chunks (PATCH). CCA uses the TUS protocol which supports "resumable uploads". There are a number of TUS clients available at the Official TUS site.
1: Create upload
Initiate patch upload.
Request
Response
2. Start the upload
Now that the upload has been initiated, start uploading the actual bytes. Use the URL in the location
header from the response in step 1 as the {UPLOAD_URL}
.
Note that this is a PATCH, and you can upload any number of bytes per request.
Request
Response
3. Get status, artifacts and create file documents
Note that before you can start polling for status, the actual file upload (see previous request) must have finished (polling for status has to do with the processing of the uploaded file).
These steps are the same as described for "Upload file - direct mode" above.
Note that the {UPLOAD_ID}
is fetched from the response header location
in the first request. The actual id is a part of the url, between the .../files/
and the +
sign (see example below).
Given this URL:
{UPLOAD_ID}
would be:
Last updated