Files api

The Files API allows you do upload/download files.

Upload file

Request

POST /api/files
...binary data in the body...

Request Headers

  • 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

Response Headers

Response body

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

Examples

JavaScript

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

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

Download file

Request

GET /api/files/myFileId?alt=media

Response

Retrieve file metadata

Request

GET /api/files/myFileId

Response

Response body

Example:

{
  "id": "aaaac2mp6yoxgaavluayxfiaae",
  "filename": "logo_green.png",
  "contentType": "image/png",
  "size": 11189,
}

Delete file

Request

DELETE /api/files/myFileId

Response

Last updated