molgenis
Search…
Files api
The Files API allows you do upload/download files.

Upload file

Request

1
POST /api/files
2
...binary data in the body...
Copied!

Request Headers

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 and multipart/form-data are allowed. See the JavaScript example for how to upload a file from a form file input.
    Response
    Status code
    Description
    201 Created
    File uploaded and file metadata created.
    403 Forbidden
    If the authenticated user does not have WRITE permissions on file metadata.

Response Headers

Name
Description
Location
Location of a newly created resource

Response body

Filemeta as returned by the 'Retrieve file metadata' endpoint.

Examples

JavaScript

1
var file = document.getElementById('my-file-input').files[0]
2
var request = new XMLHttpRequest()
3
request.open('post', '/api/files', true)
4
request.setRequestHeader("Content-Type", file.type)
5
request.setRequestHeader("Content-Length", file.size)
6
request.setRequestHeader("x-molgenis-filename", file.name)
7
request.send(file)
Copied!

cURL

curl -H 'Content-Type: application/octet-stream' --data-binary @my.file /api/files

Download file

Request

1
GET /api/files/myFileId?alt=media
Copied!

Response

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

Retrieve file metadata

Request

1
GET /api/files/myFileId
Copied!

Response

Status code
Description
200 OK
File metadata
403 Forbidden
If the authenticated user does not have READ permissions on the file metadata

Response body

Example:
1
{
2
"id": "aaaac2mp6yoxgaavluayxfiaae",
3
"filename": "logo_green.png",
4
"contentType": "image/png",
5
"size": 11189,
6
}
Copied!

Delete file

Request

1
DELETE /api/files/myFileId
Copied!

Response

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 1yr ago