Attached file, property type 'attachment' (using class 'abc/mnesia' and property 'patt' as an example)
Overview
Allows attaching a file attachment to an entity with placement on disk in a preconfigured storage associated with the class collection.
And subsequently performing operations of reading, replacing, and deleting the attachment.
Each property of type `attachment` forms a separate endpoint of this type in the REST API.
After upload the file loses its name and extension and is available for download without these characteristics under the name `content`.
Uploading a file with Content-Type: application/octet-stream and multipart/form-data is allowed. In the latter case, the first file from the list is actually saved. The original file name is taken from the Content-Disposition header and saved in the field metadata (JSON). In storage the file is placed with a special constant name.
The real path to attachments is formed the same way regardless of storage type:
For categories: `…/Domain/ClassName/Id12/Id34/Id56/IdRest/PropertyName`
For history: `…/Domain/ClassName/Id12/Id34/Id56/IdRest/PropertyName`
Requests
| HTTP verb | Endpoint | Description |
|---|---|---|
|
|
|
|
|
|
|
|
Downloading the attachment
Request
| Name | Type | Description |
|---|---|---|
|
|
Output type. Default
|
GET /rest/v1/model/abc/mnesia/68f99ca9-016c-d352-e02f-50e54938780c/patt HTTP/1.1
Uploading the attachment
Replaces the file.
A single file is uploaded either with Content-Type: multipart/formdata
or with an arbitrary non-multipart Content-Type.
If the upload uses Content-Type: multipart/formdata,
only the first file is saved (the first part having a filename field in the
Content-Disposition header), and the file name itself is ignored.
Request
PUT /rest/v1/model/abc/mnesia/68f99ca9-016c-d352-e02f-50e54938780c/patt HTTP/1.1
Content-Type: application/octet-stream
BINARY BODY OF 'app.mp3'
PUT /rest/v1/model/abc/mnesia/68f99ca9-016c-d352-e02f-50e54938780c/patt HTTP/1.1
Content-Type: multipart/form-data; boundary=-----------boundary_69df8120352a996e
-----------boundary_69df8120352a996e
Content-Type: application/octet-stream
Content-Disposition: form-data; name="abcde"; filename="app.mp3"
Content-Transfer-Encoding: binary
BINARY BODY OF 'app.mp3'
-----------boundary_69df8120352a996e--