Files api
The Files API allows you do upload/download files.
POST /api/files
...binary data in the body...
Name | Description | Required | Default value |
Content-Type * | A standard MIME type describing the format of the file | No | application/octet-stream |
Content-Length | File size in bytes | No | |
x-molgenis-filename | Filename | No | unknown |
x-molgenis-token | Authentication token | No | session cookie if supplied |
- All media types with the exception of
application/x-www-form-urlencoded
andmultipart/form-data
are allowed. See the JavaScript example for how to upload a file from a form file input.ResponseStatus codeDescription201 CreatedFile uploaded and file metadata created.403 ForbiddenIf the authenticated user does not have WRITE permissions on file metadata.
Name | Description |
Location | Location of a newly created resource |
Filemeta as returned by the 'Retrieve file metadata' endpoint.
var file = document.getElementById('my-file-input').files[0]
var request = new XMLHttpRequest()
request.open('post', '/api/files', true)
request.setRequestHeader("Content-Type", file.type)
request.setRequestHeader("Content-Length", file.size)
request.setRequestHeader("x-molgenis-filename", file.name)
request.send(file)
curl -H 'Content-Type: application/octet-stream' --data-binary @my.file /api/files
GET /api/files/myFileId?alt=media
Status code | Description |
200 OK | File downloaded |
403 Forbidden | If the authenticated user does not have READ permissions on the file metadata |
404 Not Found | If the file identifier is unknown |
GET /api/files/myFileId
Status code | Description |
200 OK | File metadata |
403 Forbidden | If the authenticated user does not have READ permissions on the file metadata |
Example:
{
"id": "aaaac2mp6yoxgaavluayxfiaae",
"filename": "logo_green.png",
"contentType": "image/png",
"size": 11189,
}
DELETE /api/files/myFileId
Status code | Description |
204 No Content | File and filemeta deleted. |
403 Forbidden | If the authenticated user does not have WRITE permissions on the file metadata |
404 Not Found | If the file identifier is unknown |
Last modified 3yr ago