The Hub provides a REST API for caching client-uploaded files. This gives you the ability to use only cached file descriptors for form processing and avoid using multipart data. Also, this feature improves user experience since the user can upload files separately—and it is faster than a batch upload.
POST /api/files/cache
Uploads a new file to cache. The file is a multipart representation of uploaded file.
Request
Here's an example request:
POST /api/files/cache HTTP/1.1
Host: localhost:8080
Content-Type: multipart/form-data
Response
- Success response: 201 Created - file was added to cache, file descriptor is returned as a result:
- Error response: 400 Bad Request - error during file upload
HTTP/1.1 201 Created
Content-Type: application/json;charset=UTF-8
{
"uuid": "89828e1e-c834-42a2-86f1-893209f63ab5",
"fileName": "my_file.pdf",
"mimeType": "application/pdf",
"size": 123123,
"expiredOn": "2020-01-01T12:00:00Z"
)
DELETE /api/files/cache/{uuid}
Removes a file containing a uuid from the cache and deletes it from the server.
- uuid: UUID of the file in the cache
Request
Here's an example request:
POST /api/files/cache/9828e1e-c834-42a2-86f1-893209f63ab5 HTTP/1.1
Host: localhost:8080
Content-Type: application/json;charset=UTF-8
Response
- Success response: 200 OK - the file was removed from the cache
- Error response: 400 Bad Request - error during file deletion. File was not deleted
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8