Files API allows to work with files in one folder. Syntax is similar to Dropbox API.
- get_metadata
- upload
- download
- list_folder
- delete
HTTP POST requests with data supplied in JSON format. JSON data is passed in request body or header depending on endpoint.
Response data is in result code, header and body.
Errors are returned using standard HTTP error code syntax.
Code Description
400 BAD_REQUEST Bad input parameter.
409 CONFLICT Specific error. Additional info is in JSON format in response body.
500 INTERNAL_SERVER_ERROR Server-side error.
Specific error has following format (JSON):
{
"id": "",
"summary": ""
}
returns file metadata including file name, size, last modified time and SHA256 hash
{
"path": "filename"
}
JSON should be passed in request body
{
"path": "filename"
"size": "size in bytes"
"modified": "last modified UNIX time"
"hash": "SHA256 hash"
}
JSON is returned in response body
deletes file
{
"path": "filename"
}
JSON should be passed in request body
{
"path": "filename of deleted file"
}
JSON is returned in response body
returns list of files
no arguments
JSON array of the following JSON values:
{
"path": "filename"
"size": "size in bytes"
"modified": "last modified UNIX time"
"hash": "SHA256 hash"
}
JSON is returned in response body
downloads file
{
"path": "filename"
}
JSON should be passed in request body
Response body contains file content
Response header File-API-Result
contains following JSON:
{
"path": "filename"
"size": "size in bytes"
"modified": "last modified UNIX time"
"hash": "SHA256 hash"
}
uploads file
Request should contain header File-API-Arg
of the following format:
{
"path": "filename"
"autorename": "boolean value - automatically rename file in case of name conflict or rewrite otherwise"
}
File content is supplied as multipart/form-data
format
Response body contains the following JSON:
{
"path": "filename"
"size": "size in bytes"
"modified": "last modified UNIX time"
"hash": "SHA256 hash"
}
To start File API Server run:
mvn exec:java
To start unit tests run:
mvn clean test