File Cache

Hub file cache REST API

Hub file cache REST API

The Hub provides a REST API for caching client-uploaded files.
This allows to use only cached file descriptors for form processing and avoid using multipart data.
Also this feature improves UX because user can upload files separately and it seems to be faster for him than batch upload
A file is always linked to an execution, so it is only possible to upload a file to cache as part of a valid execution.

POST /api/files/cache

Uploads new file to cache. Has to have Authorization header with valid JWT token.

Request:
  • file: multipart representation of uploaded file

An example request

POST /api/files/cache HTTP/1.1
Host: localhost:8080
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI1MTFiMDQ0MS1kNmQwLTRhOGEtODAwMy0yMmVmNTI3NDA4NDciLCJzdWIiOiJleGVjdXRvciIsImlhdCI6MTU1NzI0NjE4OSwiZXhwIjoxNTU3Mjc0OTg5fQ.2GVAuboArO8k1G48CY1ojFdypO9zm9u2ZubCE7Qa-Co
Content-Type: multipart/form-data
Response:
  • 201 Created, a success response, file was added to cache, file descriptor is returned as a result:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8

{ 
  "uuid": "89828e1e-c834-42a2-86f1-893209f63ab5", 
  "fileName": "my_file.pdf", 
  "mimeType": "application/pdf", 
  "size": 123123
}

  • 400 Bad Request, error during file upload,
  • 401 Unauthorized, invalid access token.

GET /api/files/cache/{uuid}

Returns file descriptor with uuid from cache. Has to have Authorization header with valid JWT token.

Request:
  • uuid: UUID of file in cache

An example request

GET /api/files/cache/9828e1e-c834-42a2-86f1-893209f63ab5 HTTP/1.1
Host: localhost:8080
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI1MTFiMDQ0MS1kNmQwLTRhOGEtODAwMy0yMmVmNTI3NDA4NDciLCJzdWIiOiJleGVjdXRvciIsImlhdCI6MTU1NzI0NjE4OSwiZXhwIjoxNTU3Mjc0OTg5fQ.2GVAuboArO8k1G48CY1ojFdypO9zm9u2ZubCE7Qa-Co
Content-Type: application/json;charset=UTF-8
Response:
  • 200 OK, a success response, with file descriptor in body:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8

{
    "execution": "59bb233b-2d2b-41e7-ad13-f17c14513603", 
    "uri": "/api/files/cache/89828e1e-c834-42a2-86f1-893209f63ab5",
    "descriptor": { 
      "uuid": "89828e1e-c834-42a2-86f1-893209f63ab5", 
      "fileName": "my_file.pdf", 
      "mimeType": "application/pdf", 
      "size": 123123
    }
}

  • 401 Unauthorized, invalid access token,
  • 404 Not Found, a file descriptor with uuid not found.