Nested file, property type 'list of attachments' (using the example of class 'abc/mnesia' and property 'patts')
Overview
Allows an arbitrary number of attachment files to be attached to an entity, with placement on disk in a preconfigured storage associated with the class collection.
And further perform operations of reading, replacing, deleting the attachment.
Each property of type `list of attachments` forms a separate endpoint of that type in REST-API. This is a field of type `attachment` with the set attribute `multi`=`true`.
A file after POST upload retains its name and extension, and when uploaded by PUT method acquires a name and extension identical to the specified attachment identifier.
It is allowed to upload several files with one POST-request in the mode `multipart/form-data`.
The actual path to attachments is formed the same regardless of the storage type:
* For categories - `…/Domain/ClassName/Id12/Id34/Id56/IdRest/PropertyName/FileName`
* For the story - `…/Domain/ClassName/PartitionFieldDate/Id12/Id34/Id56/IdRest/PropertyName/FileName`
Requests
HTTP verb | Endpoint | Description |
---|---|---|
|
|
Obtaining metadata for all attachment files associated with the property |
|
|
|
|
|
|
|
|
Uploading attachment files with saving names
Uploading to the collection is done by Content-Type: multipart/formdata
.
There can be one or more files in the request.
The files are placed under the names specified in the Content-Disposition
headers of each part.
If a file with the specified name already exists, it is not saved and returns an error. Depending on the Content-Type and the presence of successfully placed files, the request may return a failed HTTP response, or failure information in the body of the HTTP response 200 OK.
Request
POST /rest/v1/model/abc/mnesia/6f7d27df-017b-ab81-77e7-7cd30a921f58/patts HTTP/1.1
Content-Type: multipart/form-data; boundary=-----------boundary_69df8120352a996e
-----------boundary_69df8120352a996e
Content-Type: application/octet-stream
Content-Disposition: form-data; name="filename"; filename="app.mp3"
Content-Transfer-Encoding: binary
BINARY BODY OF 'app.mp3'
-----------boundary_69df8120352a996e--
Obtaining metadata for all attachment files associated with the property
Downloading a specific attachment file
Request
Name | Type | Description |
---|---|---|
|
|
Issuance Type. Default
|
GET /rest/v1/model/abc/mnesia/6f7d27df-017b-ab81-77e7-7cd30a921f58/patts/app.mp3 HTTP/1.1
Uploading an attachment file
Performs a file replacement.
A single file is uploaded either with Content-Type: multipart/formdata
,
or with an arbitrary Content-Type
that is not multipart.
If the download is done with Content-Type: multipart/formdata
,
then only the first file will be saved (the first part with the filename field in the header)
Content-Disposition
), and the file name itself will be ignored.
Request
PUT /rest/v1/model/abc/mnesia/6f7d27df-017b-ab81-77e7-7cd30a921f58/patts/app.mp3 HTTP/1.1
Content-Type: application/octet-stream
BINARY BODY OF 'app.mp3'
PUT /rest/v1/model/abc/mnesia/6f7d27df-017b-ab81-77e7-7cd30a921f58/patts/app.mp3 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--