Multimedia Management Building Block

Metadata

Multimedia Management BB handles file uploads and retrieval, each file must be labeled with a metadata structure that contains the document title, description and an optional JSON object.

Metadata Scheme

Scheme:

{
  "file": "UUID",
  "title": "String",
  "description": "String",
  "owner_id": "String",
  "optional": "JSON"
}

Example metadata:

{
  "file": "c3587905-6b83-467a-9b88-b75c3271788b",
  "title": "RD678-K Prototype",
  "description": "Prototype Schematics",
  "owner_id": "25754e48-7964-4de3-bf99-bc4069f491b0",
  "optional": {
    "department": "R&D"
  }
}

GET methods

GET /api/v1/metadata/(uuid: file)

Returns the metadata associated to the requested file.

Parameters:
  • file (UUID) – the UUID of the file metadata
Query Parameters:
 
  • access_token (string) – valid access token for OAuth2 authentication
Status Codes:

Example request:

GET /api/v1/metadata/c3587905-6b83-467a-9b88-b75c3271788b HTTP/1.1
Host: example.com
Accept: application/json

Example response:

HTTP/1.1 200 OK
Content-type: application/json

{
  "file": "c3587905-6b83-467a-9b88-b75c3271788b",
  "title": "RD678-K Prototype",
  "description": "Prototype Schematics",
  "owner_id": "25754e48-7964-4de3-bf99-bc4069f491b0",
  "optional": {
    "department": "R&D"
  }
}
GET /api/v1/files/(uuid: file)

Returns the requested file.

Parameters:
  • file (UUID) – the UUID of the file
Query Parameters:
 
  • access_token (string) – valid access token for OAuth2 authentication
Request Headers:
 
  • Accept – the response content type depends on the uploaded file
Status Codes:

Example request:

GET /api/v1/files/c3587905-6b83-467a-9b88-b75c3271788b HTTP/1.1
Host: example.com
Accept: */*

Example response:

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 93

RD678-K Prototype
=================

Bill Of Materials
^^^^^^^^^^^^^^^^^

* rd-7864
* TI2865

POST methods

POST /api/v1/upload

Uploads a new file, it must be a multipart/related or a multipart/form-data request.

multipart/related
the first part must be the metadata JSON encoded (see Metadata) and the second part must be the file form-data encoded.
multipart/form-data
the fields must be named like in Metadata and the file part must be named upload.

In both cases the file keys is a server generated UUID and must be saved in order to retrieve the file.

This call returns the metadata uploaded with the generated UUID.

Request Headers:
 
Query Parameters:
 
  • access_token (string) – valid access token for OAuth2 authentication
Request JSON Object:
 
  • title (string) – the file title
  • description (string) – a summary of the uploaded file
  • optional (json) – an optional JSON object, may be omitted
Form Parameters:
 
  • file – the file to upload
Response JSON Object:
 
  • file (UUID) – the generated file unique identifier
  • title (string) – the file title
  • description (string) – a summary of the uploaded file
  • owner_id (string) – the identifier of the user performing the request
  • optional (json) – an optional JSON object, may be omitted
Status Codes:
  • 200 OK – uploaded successuflly

Example request:

POST /api/v1/upload HTTP/1.1
Host: example.com
Content-Length: 498
Content-Type: multipart/related; boundary="2585f99cfa2d4d896e8363ed2a715d10917981a30f99711831a4cdcdd6e5"

--2585f99cfa2d4d896e8363ed2a715d10917981a30f99711831a4cdcdd6e5
Content-Type: application/json

{"description":"Prototype Schematics","title":"RD678-K Prototype"}
--2585f99cfa2d4d896e8363ed2a715d10917981a30f99711831a4cdcdd6e5
Content-Disposition: form-data; name="file"; filename="bom.rst"
Content-Type: application/octet-stream

RD678-K Prototype
=================

Bill Of Materials
^^^^^^^^^^^^^^^^^

* rd-7864
* TI2865

--2585f99cfa2d4d896e8363ed2a715d10917981a30f99711831a4cdcdd6e5--

Example response:

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 112

{
  "file":"518f8f4a-3d28-4ac1-9eda-4b9a795a9619",
  "title":"RD678-K Prototype",
  "description":"Prototype Schematics",
  "owner_id": "25754e48-7964-4de3-bf99-bc4069f491b0"
}