Skip to content

Files

The Files module is responsible for storing and serving files. It provides a REST API for uploading, downloading, and managing files. It supports various file types, including images, videos, PDFs, and more.

Features

Category Details
Flexibility Common mimetypes: Video, Images, PDF, Excel, Word, Text Files, Markdown, and others
Availability Video Media Converter: Converts *.MOV to *.MP4 for better support in modern browsers
Availability File Converter: Excel (xlsx) to JSON, XML; XML to JSON
Performance Image Optimization and Scaling
Performance Support for Etag and Last-Modified HTTP Headers
Performance Range Processing for videos

Upload

Upload a file to a repository that is not registered

HTTP
POST {{host}}/api/core/files
Accept: application/json
Content-Type: multipart/form-data; boundary=--MyBoundary
Authorization: Basic api:{{token}}

----MyBoundary
Content-Disposition: form-data; name="file"; filename="image.jpg"
Content-Type: image/jpeg

< ./tests/test-files/hamster.jpg
----MyBoundary--

Upload v2 file to a repository registered in [app].[files] object

HTTP
POST {{host}}/api/core/files/uploadv2/{{appname}}?file_remote_uuid=fc5ec332-9a3d-4f0d-97d7-f6f854fd186a
Accept: application/json
Content-Type: multipart/form-data; boundary=--MyBoundary
Authorization: Basic api:{{token}}

----MyBoundary
Content-Disposition: form-data; name="file"; filename="image.jpg"
Content-Type: image/jpeg

< ./tests/test-files/hamster.jpg
----MyBoundary--
  • file_url - optional URL from the local instance > must generate the file
  • file_name - optional, if not set then saved to the repository
  • file_remote_uuid - required
  • file_remote_source
  • file_description
  • file_type
  • pjob=true - default false generate as a task

Example

HTTP
POST {{host}}/api/core/files/uploadv2?file_url=%2Fapi%2Fcore%2Fsrs%2F111%2Fumowa.hbs.pdf%id%3Dc8813f8b-716d-ec11-aa8c-049674ee0f2a

Upload v2 file to a repository

HTTP
1
2
3
4
5
6
7
POST {{host}}/api/core/files/uploadv2?
    file_remote_source=expense&
    file_type=agreement&
    file_name=umowa&
    file_remote_uuid=f3ed8bb9-8551-4e25-b5b5-af3eb19852d3&
    file_url=%2Fapi%2Fcore%2Fsrs%2F111%2Fumowa.hbs.pdf%id%3Dc8813f8b-716d-ec21-aa8c-064674ee0f8a&file_type=agreement
Authorization: Basic api:{{token}}

Download

Get a file from the repository

Query parameters:

  • name - optional, if not set then the original name will be used
  • msg404 - optional, if not set then 404 will be returned, if set then a file will be created with the message as content
  • w, h, options - optional, if set then the image will be resized and optimized

Get file

HTTP
GET {{host}}/api/core/files/{{file_hash}}.jpg

Download a file with a custom name

HTTP
GET {{host}}/api/core/files/{{file_hash}}.jpg?name=custom_name.jpg

Resize file

HTTP
GET {{host}}/api/core/files/{{file_hash}}.jpg?w=400

Custom image when file not found (Response code 200)

HTTP
GET {{host}}/api/core/files/{{file_hash}}.mov?msg404=File-not-found

XML as JSON

  • max file size 10 MB
HTTP
GET {{host}}/api/core/files/{{file_hash}}.xml?o=json

Excel XLSX as JSON

Notes:

  • maximum file size 10 MB
  • optional parameter images for example ?o=json-images for parsing attached embeded images, image will be save to iamge store and cell value will be replaced with link example /api/core/files/4921700d-221d-9e66-cadf-7ba171e6c2s9.jpeg
HTTP
GET {{host}}/api/core/files/{{file_hash}}.xlsx?o=json

Excel XLSX as XML

Notes:

  • maximum file size 10 MB
  • optional parameter images for example ?o=json-images for parsing attached embeded images, image will be save to iamge store and cell value will be replaced with link example /api/core/files/4921700d-221d-9e66-cadf-7ba171e6c2s9.jpeg
HTTP
GET {{host}}/api/core/files/{{file_hash}}.xlsx?o=xml

Videos, MOV files

  1. Requesting a mov file by default will return an optimized mp4 file if it exists in the repository.
  2. If the MOV file does not exist but an optimized MP4 file exists, then the MP4 will be returned.
  3. A poster will be generated from the first second of the video with a .jpg extension.