OSLC attachment processing
Attachment processing in OSLC involves processing the attachment itself, which is an unstructured document, and processing the associated metadata for that document.
The metadata is described in an AttachmentDescriptor resource RDF. AttachmentDescriptor resources are always associated with an attachment in a 1:1 relationship.
Creating OSLC attachments
You create attachments by using the HTTP POST method with binary content. Do not use multi-part HTTP POST requests.The following example shows an HTTP request to create an attachment to show an image of a broken part:
POST http://yourserver/oslc/os/oslcwodetail/_abcd123/attachments
Slug: brokenpart.jpeg
Content-Type: image/jpeg
Content-Length: 18124
x-document-description: A broken part
x-document-meta: Attachment
[binary content]
The following example shows the response to the request:
HTTP/1.1 201 CREATED
Location: http://yourserver/oslc/os/oslcwodetail/_abcd123/attachments/1
Link: <http://yourserver/oslc/os/oslcwodetail/_abcd123/attachments/meta/1>;
rel="describes"
Content-Length: 0
The Slug header indicates the file name. You can use the header x-document-description to describe the attachment. This description is mapped to dcterms:description of the attachment descriptor resource. You can use the x-document-meta header to indicate the folder name for storing the attachment.
Updating OSLC attachments
You can update OSLC attachments by using the HTTP PUT method with binary content. Do not use multipart HTTP PUT requests.
The following example shows HTTP request to update an attachment:
PUT http://yourserver/oslc/os/oslcwodetail/_abcd123/attachments/1
Slug: brokenpart2.jpeg
Content-Type: image/jpeg
Content-Length: 18124
x-document-description: A broken part
x-document-meta: Attachment
[binary content]
The following example shows the response to the request:
HTTP/1.1 204
Content-Length: 0
To update just the description of the attachment, you can use a PATCH request to the meta URI, as shown in the following example:
PATCH http://yourserver/oslc/os/oslcwodetail/_abcd123/attachments/meta/1
Content-Type: application/json
{
“dcterms:description”: “Broken pipe”
}
Selecting OSLC attachments
/oslc/os/oslcwodetail?oslc.select=res1,res2,spi:attachments{*}
Deleting OSLC attachments
To delete OSLC attachments, use the following request:
DELETE <attachment uri>