Creating Binary Content items
To create a binary content item such as an image, video, sound clip or
a Word or PDF attachment you first need to upload the binary object
the content item is to contain. You do this by
POST
ing it to a fixed web service URL for binary
attachments:
curl --include -u user:password -X POST -H "Content-Type: image/png" --upload-file my-image.png \>
http://host-ip-address/webservice/escenic/binaryHTTP/1.1 100 Continue HTTP/1.1 201 Created Server: Apache-Coyote/1.1 X-ECE-Active-Connections: 1 Location: http://
host-ip-address/webservice/escenic/binary/-1/2014/8/26/7/dc2dd7d4-ab5d-46d7-8248-ee5b0c0d2268.bin Content-Length: 0 Date: Tue, 26 Aug 2014 05:23:12 GMT
Make sure that the Content-Type
header is set
correctly for the type of file you are uploading. The
Location
field of the response contains the URL of
the uploaded file. You can then use this URL to construct an Atom
entry resource for the content item:
<?xml version="1.0" encoding="UTF-8"?> <entry xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:metadata="http://xmlns.escenic.com/2010/atom-metadata" xmlns:dcterms="http://purl.org/dc/terms/"> <title type="text">basic-grid.png</title> <app:control> <app:draft>yes</app:draft> </app:control> <content type="application/vnd.vizrt.payload+xml"> <vdf:payload xmlns:vdf="http://www.vizrt.com/types" model="http://host-ip-address/webservice/escenic/publication/pub-name/model/content-type/content-type-name"> <vdf:field name="name"> <vdf:value>basic-grid.png</vdf:value> </vdf:field> <vdf:field name="description"/> <vdf:field name="location"/> <vdf:field name="photographer"/> <vdf:field name="alttext"/> <vdf:field name="copyright"/> <vdf:field name="binary"> <vdf:value> <link rel="edit-media" href="http://host-ip-address/webservice/escenic/binary/-1/2014/8/25/15/7123b4f2-658b-4ec5-8ced-4e4e914679c7.bin" type="image/png" title="basic-grid.png"/> </vdf:value> </vdf:field> <vdf:field name="com.escenic.tags"> <vdf:list/> </vdf:field> </vdf:payload> </content> </entry>
Make sure that:
-
The
vdf:payload
element'smodel
attribute references an appropriate binary content type: in this case it needs to be a content type designed to hold images -
The
link
element'srel
attribute is set toedit-media
-
The
link
element'stype
attribute is set to the same value as you specified when uploading the binary object -
The
link
element'shref
attribute is set to URL returned when you uploaded the binary object
You can now upload the Atom entry resource in the same way as for any other content item (see Create a Content Item).