Chunk Upload Developer's Guide

For background and reference information about the API see http://www.assetbank.co.uk/go/knowledgebase/asset-bank-API.html

Summary

This is a step by step guide to uploading a large file by breaking the file into chunks and submitting each chunk separately.

Steps

  1. get api URLs
  2. create new chunked file
  3. upload chunks
  4. create asset
  5. update asset bank with file from uploaded chunks

Get API URL

It is recommended to code against the API using the following root request to look up the URLs rather than hard code the urls directly as this will ensure that new versions of the API do not introduce incompatibility issues.

For example, from the response JSON structure, select the version of the API and look up the URL for the API resource (e.g. api_version_1_3.tempChunkedFileUrl).

Request

curl -X GET -H "Accept: application/json" "http://127.0.0.1:8080/asset-bank/rest/"

Response

"api_version_1_1": {

		"assetsUrl": "http://127.0.0.1:8080/asset-bank/rest/v1.2/assets",

		"checkoutUrl": "http://127.0.0.1:8080/asset-bank/rest/checkout",

		"editorDependenciesUrl": "http://127.0.0.1:8080/asset-bank/rest/editor-dependencies",

		"lightboxesUrl": "http://127.0.0.1:8080/asset-bank/rest/v1.1/lightboxes",

		"signingUrl": "http://127.0.0.1:8080/asset-bank/rest/sign-url"

	},

	"api_version_1_2": {

		"accessLevelSearchUrl": "http://127.0.0.1:8080/asset-bank/rest/access-level-search",

		"assetSearchUrl": "http://127.0.0.1:8080/asset-bank/rest/asset-search",

		"assetsUrl": "http://127.0.0.1:8080/asset-bank/rest/v1.2/assets",

		"attributesUrl": "http://127.0.0.1:8080/asset-bank/rest/attributes",

		"categorySearchUrl": "http://127.0.0.1:8080/asset-bank/rest/category-search",

		"checkoutUrl": "http://127.0.0.1:8080/asset-bank/rest/checkout",

		"displayAttributeGroupUrl": "http://127.0.0.1:8080/asset-bank/rest/display-attribute-groups",

		"editorDependenciesUrl": "http://127.0.0.1:8080/asset-bank/rest/editor-dependencies",

		"lightboxesUrl": "http://127.0.0.1:8080/asset-bank/rest/lightboxes",

		"publishingActionsUrl": "http://127.0.0.1:8080/asset-bank/rest/publishing-actions",

		"signingUrl": "http://127.0.0.1:8080/asset-bank/rest/sign-url",

		"userSearchUrl": "http://127.0.0.1:8080/asset-bank/rest/user-search",

		"usersUrl": "http://127.0.0.1:8080/asset-bank/rest/users"

	},

	"api_version_1_3": {

		"accessLevelSearchUrl": "http://127.0.0.1:8080/asset-bank/rest/access-level-search",

		"assetSearchUrl": "http://127.0.0.1:8080/asset-bank/rest/asset-search",

		"assetsUrl": "http://127.0.0.1:8080/asset-bank/rest/assets",

		"attributesUrl": "http://127.0.0.1:8080/asset-bank/rest/attributes",

		"categorySearchUrl": "http://127.0.0.1:8080/asset-bank/rest/category-search",

		"checkoutUrl": "http://127.0.0.1:8080/asset-bank/rest/checkout",

		"displayAttributeGroupUrl": "http://127.0.0.1:8080/asset-bank/rest/display-attribute-groups",

		"editorDependenciesUrl": "http://127.0.0.1:8080/asset-bank/rest/editor-dependencies",

		"lightboxesUrl": "http://127.0.0.1:8080/asset-bank/rest/lightboxes",

		"publishingActionsUrl": "http://127.0.0.1:8080/asset-bank/rest/publishing-actions",

		"signingUrl": "http://127.0.0.1:8080/asset-bank/rest/sign-url",

		"tempChunkedFileUrl": "http://127.0.0.1:8080/asset-bank/rest/temp-chunked-file",

		"userSearchUrl": "http://127.0.0.1:8080/asset-bank/rest/user-search",

		"usersUrl": "http://127.0.0.1:8080/asset-bank/rest/users"

	}

}

Create new chunked file

Create the chunked file to obtain the URL to be used during upload of the chunks.

Request

curl -v -X POST -H "Content-type: application/json" http://127.0.0.1:8080/asset-bank/rest/temp-chunked-files 

Response

201 Created
Location: http://127.0.0.1:8080/asset-bank/rest/temp-chunked-files/067e6162-3b6f-4ae2-a171-2470b63d

Upload separate chunks sequentially

Using the URL returned previously, upload each chunk of file, appending the index of the piece to the URL.

Request #1

curl -v -X PUT -T /path/to/example-part1.dat -H "Content-Type: application/octet-stream" http://127.0.0.1:8080/asset-bank/rest/temp-chunked-files/067e6162-3b6f-4ae2-a171-2470b63d/0

Request #2

curl -v -X PUT -T /path/to/example-part2.dat -H "Content-Type: application/octet-stream" http://127.0.0.1:8080/asset-bank/rest/temp-chunked-files/067e6162-3b6f-4ae2-a171-2470b63d/1

Response

200 OK

Create asset

Create an asset (using access levels).

Request

curl -v -X POST -H "Content-type: application/json" --data '{"accessLevels": [{"id":5}, {"id": 1}]}' http://127.0.0.1:8080/asset-bank/rest/assets

Response

201 Created
Location: http://127.0.0.1:8080/asset-bank/rest/assets/1

Put chunked file into Asset Bank from uploaded chunks.

Set the header field 'X-Copy-Temp-Chunked-File' to be the URL used to upload the chunks when invoking the assets API to set the content of a particular asset to be the uploaded file joined in sequence according to the indices supplied.

Request

curl -v -X PUT -T /path/to/example.dat -H "Content-Type: application/octet-stream" -H "Content-Disposition: attachment; filename=68.jpg" -H "X-Copy-Temp-Chunked-File: http://127.0.0.1:8080/asset-bank/rest/temp-chunked-files/067e6162-3b6f-4ae2-a171-2470b63d" http://127.0.0.1:8080/asset-bank/rest/assets/1/content

Response

200 OK

Was this article helpful?

Yes No

Thanks for your feedback!