2011-05-27

Using the AttachFS Protocol Bundle

The AttachFS protocol bundle provides a very simple means of accessing attachment and document content as well as creating attachments. The AttachFS protocol bundle is available at the server root “/attachfs”. Access to content via AttachFS requires HTTP authentication to be performed – just as when accessing the server's WebDAV presentation.

Viewing and Downloading Content
$ curl -o file.ods -u awilliam http://127.0.0.1:8080/attachfs/view/iwuV3AmSvh-10100-vdqs37MIYu-1305887683970458@227fd7d5-0c5e-4074-b2f0-7470a8dadddd
$ curl -o file.ods -v -u awilliam http://127.0.0.1:8080/attachfs/view/11124685
The first curl operation requests an attachment from AttachFS; the second curl operation requests the document with objectId#11124685/
Both attachments and documents can be viewed by requesting the id from the “/attachfs/view/” location or downloaded from the “/attachfs/download/” location. The server will determine if the requested content is from an attachment or a document entity by examination of the requested name. For either attachments or documents transformations can be performed using an OSSF chain.

Creating An Attachment

$ curl -u awilliam -T OGo18215321.ods \
    -H 'Content-Type: vnd.oasis.opendocument.spreadsheet'
    http://127.0.0.1:8080/attachfs/10100/OGo18215321.ods
This curl command will create an attachment with the webdav_uid of "OGo18215321.ods" related to the entity 10100 and with the specified MIME type.
Performing an HTTP PUT operation to the “/attachfs/{name}” location will create a new attachment with the specified name. The attachment id will be returned in the “Etag” attribute of the HTTP 201 response to the PUT request. This attachment will not be related to any entity.

An attachment can also be created by performing the HTTP PUT to the path “/attachfs/{objectId}/{name}” which will create an attachment related to the entity whose objectId is specified in the path. The name of that attachment will be preserved.

No comments:

Post a Comment