The File service manages downloading of files in CCA. The examples in the documentation uses cURL
to show how the API works.
Download a file step-by-step
Downloading a file includes a number of subsequent requests described below.
1: Create download
In this step, the download of a file is initiated.
Request
Copy curl --location --request POST 'https://cca-eu-west-1.saas-stage.infomaker.io/twirp/cca.Files/CreateDownload' \
--header 'Authorization: Bearer {TOKEN}' \
--header 'Content-Type: application/json' \
--data-raw '{
"UUID": "{FILE_DOCUMENT_UUID}",
"Type": {DOWNLOAD_TYPE}
}'
The {FILE_DOCUMENT_UUID}
is the uuid for the file's corresponding document in the repository.
The {DOWNLOAD_TYPE}
is optional and should be either 1
to download the original asset or 2
to download the presentation copy.
Response
The response when only using UUID:
Copy HTTP/2 200
content-type: application/json ; charset = utf-8
{
"downloadId" : "ee0552c8-a547-59a2-8fc0-c069f624093a_21aa83cdd65ace2561c3d9db01eb0a291fd64aab4846e014cd293d3157aea9c11aa5bb0a3abb8af023368db40c6ed5c63e94d90c56fe0c725a932e79863e623f"
}
The returned downloadId
is used to identify this specific download and is used in the subsequent requests.
The response when using Type:
Copy HTTP/2 200
content-type: application/json ; charset = utf-8
{
"manifest" : {
"uuid" : "ee0552c8-a547-59a2-8fc0-c069f624093a" ,
"uri" : "im://image/hW5kiMRr8wjjmlQEjqDyx9csCOg.jpg" ,
"contentClass" : "image" ,
"artifacts" : [{
"type" : "download-url" ,
"value": "https://cca-presentation-area-cca-eu-west-1-dev.s3.eu-west-1.amazonaws.com/current-org/image/ee0552c8-a547-59a2-8fc0-c069f624093a?X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=ASIAUQKJNC2JLFKJVUKU%2F20200311%2Feu-west-1%2Fs3%2Faws4_request\u0026X-Amz-Date=20200311T063035Z\u0026X-Amz-Expires=900\u0026X-Amz-Security-Token=IQoJb3JpZ2luX2VjECcaCWV1LXdlc3QtMSJHMEUCIQCkFoMnxkBwsC42FbXjWcxNnnMbUfRmUiQ1kTqMcit93wIgYTIikVigeOzCMBRGO9mWsd9etjTCsJsz6y%2Ffst%2BoY8Eq5gEIEBAAGgwzMDk5Mjg0NjYwNjYiDCmg5SrXfahrvGG5%2BirDAdgtCsUnakobQxsk6MZdKNUQDooHBOWV9dUoqnbjTyQsK8mjzoTrPVkLoPErHW1MzKbHC08jTMnX0U59YKXms5IIlEBLTztPOTltd9P5HRAAzPAK998QLRukCBERDNCpiOb2kKFJmxcbY6sw06WN602nx38z1gp9scvKTllz1dQ9rmodu5So73BjGduC%2Fubb%2FTn8YDLvGqvJAPfl4%2Fb%2FlkvqoCPGx9NFV7DqJEBtTxsPPFbujrvYO4MVMIHFtMMIa2aZPzCKi6LzBTrgAYnh4zb5tZ%2BUptNy2qe%2BN0dEONjBGWu7NJ2xesAm1gTjvXPt7ydZyerNe5G9%2Fl1zdO5E%2BqPtqQyIo92oHdylOXNcwfzXR0%2FAdu5hikiaEmtgUEMYNWdFEmHEE%2F%2FDpN5GUiHMOGyR%2Bx6Q3hfCNdhkaZB2IsKyuY6ipzcBVGDEiqk2mqGul5gDSFyUedjPGMItC8MINkQf71jpzAJIma7P2ZG3JaX3jPxKEdJcEtrXiWAWbSjLy%2BiNGJhp0%2BRifsaoI6P7EK8Vjfy8rqMOsmPeHZnHnYi5NJ5364E%2B99nwvDbQ\u0026X-Amz-SignedHeaders=host\u0026X-Amz-Signature=3c7eef95696d0379184b832fa0e56f403d3fb1028153081b8c4de8c234e32956"
}]
}
}
As part of the response, CCA has created a manifest
for the download containing:
uuid
- The v5 uuid for the corresponding metadata document in the repository
uri
- The uri for the file
contentClass
- Type of file
artifacts
- These are the artifact created as part of the download
The artifact download-url
is a S3 presigned URL with a lifespan of 15 minutes. Use this URL to download the actual file.
2. Get Status for download
At this point, CCA has started, asynchronously, to process the file for downloading. In order to know when the downloaded file is done and available, you need to poll CCA for status.
Request
Copy curl --location --request POST 'https://cca-eu-west-1.saas-stage.infomaker.io/twirp/cca.Files/GetDownloadStatus' \
--header 'Authorization: Bearer {TOKEN}' \
--header 'Content-Type: application/json' \
--data-raw '{
"downloadId": "{DOWNLOAD_ID}"
}'
The {DOWNLOAD_ID}
is the downloadId returned by "1: Create download" request.
Response
Until CCA is done processing the download, the response would be:
Copy HTTP/2 200
content-type: application/json ; charset = utf-8
{
"status" : "IN_PROGRESS"
}
When CCA is finished processing the download, the response will be:
Copy HTTP/2 200
content-type: application/json ; charset = utf-8
{
"status" : "DONE" ,
"manifest" : {
"uuid" : "ee0552c8-a547-59a2-8fc0-c069f624093a" ,
"hashedFilename" : "hW5kiMRr8wjjmlQEjqDyx9csCOg.jpg" ,
"uri" : "im://image/hW5kiMRr8wjjmlQEjqDyx9csCOg.jpg" ,
"contentClass" : "image" ,
"artifacts" : [{
"type" : "image-url" ,
"value": "https://cca-download-area-cca-eu-west-1-dev.s3.eu-west-1.amazonaws.com/image/ee0552c8-a547-59a2-8fc0-c069f624093a_21aa83cdd65ace2561c3d9db01eb0a291fd64aab4846e014cd293d3157aea9c11aa5bb0a3abb8af023368db40c6ed5c63e94d90c56fe0c725a932e79863e623f/hW5kiMRr8wjjmlQEjqDyx9csCOg.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=ASIAUQKJNC2JLFKJVUKU%2F20200311%2Feu-west-1%2Fs3%2Faws4_request\u0026X-Amz-Date=20200311T063035Z\u0026X-Amz-Expires=900\u0026X-Amz-Security-Token=IQoJb3JpZ2luX2VjECcaCWV1LXdlc3QtMSJHMEUCIQCkFoMnxkBwsC42FbXjWcxNnnMbUfRmUiQ1kTqMcit93wIgYTIikVigeOzCMBRGO9mWsd9etjTCsJsz6y%2Ffst%2BoY8Eq5gEIEBAAGgwzMDk5Mjg0NjYwNjYiDCmg5SrXfahrvGG5%2BirDAdgtCsUnakobQxsk6MZdKNUQDooHBOWV9dUoqnbjTyQsK8mjzoTrPVkLoPErHW1MzKbHC08jTMnX0U59YKXms5IIlEBLTztPOTltd9P5HRAAzPAK998QLRukCBERDNCpiOb2kKFJmxcbY6sw06WN602nx38z1gp9scvKTllz1dQ9rmodu5So73BjGduC%2Fubb%2FTn8YDLvGqvJAPfl4%2Fb%2FlkvqoCPGx9NFV7DqJEBtTxsPPFbujrvYO4MVMIHFtMMIa2aZPzCKi6LzBTrgAYnh4zb5tZ%2BUptNy2qe%2BN0dEONjBGWu7NJ2xesAm1gTjvXPt7ydZyerNe5G9%2Fl1zdO5E%2BqPtqQyIo92oHdylOXNcwfzXR0%2FAdu5hikiaEmtgUEMYNWdFEmHEE%2F%2FDpN5GUiHMOGyR%2Bx6Q3hfCNdhkaZB2IsKyuY6ipzcBVGDEiqk2mqGul5gDSFyUedjPGMItC8MINkQf71jpzAJIma7P2ZG3JaX3jPxKEdJcEtrXiWAWbSjLy%2BiNGJhp0%2BRifsaoI6P7EK8Vjfy8rqMOsmPeHZnHnYi5NJ5364E%2B99nwvDbQ\u0026X-Amz-SignedHeaders=host\u0026X-Amz-Signature=3c7eef95696d0379184b832fa0e56f403d3fb1028153081b8c4de8c234e32956"
}]
}
}
As part of the response, CCA has created a manifest
for the download containing:
uuid
- The v5 uuid for the corresponding metadata document in the repository
hashedFilename
- The hashed name for the file
uri
- The uri for the file
contentClass
- Type of file
artifacts
- These are the different artifacts created as part of the download
The artifact {CONTENT_CLASS}-url
, e.g. "image-url", is a S3 presigned URL with a lifespan of 15 minutes. Use this URL to download the actual file.
If there was an error processing the download, the response will have "status": "ERROR"
and an error message will be supplied.