The payload or represenatation of an entity can be retrieved by a simple GET request. The content-disposition is controlled by the URL.
For these examples 123,456 is the object id of an entity to which the user has read privileges.
To retrieve an entity with downlaod (Save-As) disposition:
curl -u $LOGNAME -o myfile.txt http://coils.example.com/attachfs/download/123456
To retrieve an entity with inline (View) disposition:
curl -u $LOGNAME -o myfile.txt http://coils.example.com/attachfs/view/123456
The ability to request a specific content dispositions allows AttachFS to be easily used when embedding requests to resources in web pages, etc...
If the requested id is non-numeric it is assumed that the id represents the GUID of an [Attachment].
For [Document] and [Attachment] entities the payload returned is the contents of the document or attachment; this will include setting the Content-Type of the response to the appropriate value (the value stored with the document or attachment).
If the object id is that of a [Process] entity the processes' workflow log will be returned as a "text/plain" document.
If the object is is that of a [Contact] entity AttachFS supports two modes. The default mode is vCard, in which case a vCard representing the contact is returned. If the "photo" mode is specified the photo associated with the contact is returned; if the contact has no photo the thumbnail defined for the "text/vcard" mime-type is returned.
For this example OGo#123456 is a [Folder] entity in a [Project] on which the user has write access.
curl -u $LOGNAME -T /etc/passwd http://coils.example.com/attachfs/123456/passwd.txt?mode=file
This creates a file named passwd.txt in the folder with the id of 123456.
For this example OGo#123456 is a [Document] entity in a [Folder] of a [Project] on which the user has write privileges.
curl -u $LOGNAME -T /etc/passwd http://coils.example.com/attachfs/123456/*?mode=file
This will update the contents of the document with the id of 123456 without changing the name of the document. It will also update the MIME-Type and mark the file as non-transient (permanent).
For this example OGo#123456 is a [Document] entity in a [Folder] of a [Project] on which the user has write privileges.
curl -u $LOGNAME -T /etc/passwd http://coils.example.com/attachfs/123456/pablo.txt?mode=file
This will update the contents of the document with the id of 123456 and set the name to "pablo.txt". It will also update the MIME-Type and mark the file as non-transient (permanent).
It is also possible to update the a document in this manner using the the object if of the folder containing the document and the name of the file (next example).
For this example OGo#123456 is a [Folder] entity in a [Project] on which the user has write privileges.
curl -u $LOGNAME -T /etc/passwd http://coils.example.com/attachfs/123456/stanley.txt?mode=file
If a file named "stanley.txt" exists in the folder with the entity of 123456 its contents will be updated. If no such file exists in the folder then a new document document named "stanley.txt" will be created. In either case the document will be non-transient and the Content-Type of the upload will be stored as the document's MIME-Type
Via AttachFS any proper entity can be deleted by its object id; provided the user has sufficient privileges and no constraints prevent the deletion.
curl -u $LOGNAME -X DELETE 'http://coils.example.com/attachfs/87979769'
The above example deletes the entity with an object id of 87,979,769.
In this example 10100 is any proper entity the user has read access to.
curl -u $LOGNAME -T OGo18215321.ods \ -H 'Content-Type: vnd.oasis.opendocument.spreadsheet' http://coils.example.co/attachfs/10100/OGo18215321.ods
The above will store the contents of the file "OGo18215321.ods" as a new attachment to the entity with the object 10,100. The name "OGo18215321.ods" will be stored as a label of the attachment - but [Attachment] entities are always identified by the automatically generated GUID value. The GUID value of an [Attachment] is returned to the client as the "Etag" value. As the contents of an [Attachment] cannot be modified - only new [Attachment] entities can be created] - no version information is required for an [Attachment]'s etag.
If a document is readable by the Network Context (anonymous) via ACLs it can be retrieved without autentication by making the AttachFS request to "/public"
curl myfile.txt http://coils.example.com/public/view/123456
News: 2013/04/opengroupware-coils-0149rc22-uploaded
Wiki: Attachment
Wiki: Clients
Wiki: Contact
Wiki: Document
Wiki: Folder
Wiki: Model
Wiki: Process
Wiki: Project
Wiki: attachment