Hi All,
Enginio file handling REST APIs were just updated a bit. Changes:
File object is automatically attached to owning data object when the file content upload completes
File download is authenticated with similar HTTP header based mechanism as other Enginio REST API’s
Content-Range header usage is now according to RFC 2616
At same time corresponding parts of previous file handling REST API were deprecated. See details about changes and deprecated things below.
Note for Qt library users Same changes are also being implemented to the library and updated library shall be published in few weeks. So stay tuned!
Automatic file attach to owning object
File object is now automatically attached to owning data object when the file content upload completes. (Previously the attachment needed a separate object update request from the client.)
For automatic file attachment, the file creation request needs information about the data object and its target file property. So from now on, file creation request (i.e. HTTP POST to /v1/files) expects data like this:
{
"targetFileProperty": {
"id": "CBD000789012BBB678900AA",
"objectType": "objects.images",
"propertyName": "photoFile"
},
"file": {
"fileName": "zoo.png"
}
}
Note:
Automatic file attachment can be used to attach initial file to data object or later to update the file to a new one
File ref in owning data object is updated when the content upload completes. So those objects which file upload is still ongoing, can be filtered from a list of objects by simply checking that the file ref has non-null value: q = { “myFileProperty”: { “$ne”: null } }
Previous file creation request data format is now DEPRECATED and will stop working at end of August 2013.
File download authentication
File download is now a two step process:
First client asks a download URL for certain file object
And then downloads the actual file content via URL received from step 1
The file download URL is requested with HTTP GET to /v1/files/{file_id}/download_url?variant={variant_name}
Variant_name is optional parameter. If Variant_name is not given, download URL for the original file is returned.
Client’s access rights to file content is checked in download URL request. It uses similar HTTP header based approach as other Enginio REST APIs.
Returned JSON data contains an URL from where the file content can be then downloaded with HTTP GET. Returned URL expires and works only for some minutes.
Previous file download mechanism based on URL field in object JSON is now DEPRECATED and will stop working at end of August 2013.
Content-Range header usage
When uploading file content in chunks, chunk position is told with HTTP header
Content-Range: bytes {chunkStart}-{chunkEnd}/{totalFileSize}
Now the Content-Range usage follows details specified in RFC 2616. I.e.
Word “bytes” must be present in the beginning of value
When file content is streamed and totalFileSize is unknown, “*” can be given as totalFileSize. In final chunk the totalFileSize is passed with correct value.
Note that chunks must be still uploaded sequentially one-by-one.
Previous way of using Content-Range header is now DEPRECATED and will stop working at end of August 2013.
↧