REST APIs

Rest api for files

Prefix: /internal/services/files/v1/

General

Get file metadata (check user belongs to comapny)

GET /internal/services/files/v1/:company_id/files/:file_id

This route is called to get the metadata related to the file_id mentioned in the URL

Response:
  {
    "resource": {
        "company_id": "uuid-v4",
        "id": "uuid-v4",
        "application_id": "string",
        "created_at": "number",
        "encryption_key": "",
        "metadata": {
            "name": "string",
            "mime": "string"
        },
        "thumbnails": [
            {
                "index": number,
                "id": "string,
                "size": number,
                "type": "string",
                "width": number,
                "height": number
            }
        ],
        "updated_at": number,
        "upload_data": {
            "size": number,
            "chunks": number
        },
        "user_id": "uuid-v4"
    }
  }

Download a file

GET /internal/services/files/v1/companies/:company_id/files/:file_id/download

This route is called to download the file related to the file_id mentionned in the URL

Download thumbnails

GET /internal/services/files/v1/companies/:company_id/files/:file_id/thumbnails/:id

This route is called to download the thumbnail related to the file_id mentionned in the URL

Delete a file

DELETE /internal/services/files/v1/companies/:company_id/files/:file_id

This route is called to delete the file related to the file_id mentionned in the URL

Classic upload

To upload a single file, you must call this route and put the file binary data into a "file" multipart section.

Upload a file

POST /internal/services/files/v1/companies/:company_id/files?thumbnail_sync=1

This route is called to upload a file when chunk upload is not necessary. Thumbnail_sync: when set then backend will wait up to 10 seconds for preview to be generated before reply.

Query Parameters

NameTypeDescription

thumbnail_sync

boolean

Request Body

NameTypeDescription

File

object

The file which will be uploaded

response : 
  {
    "resource": {
        "company_id": "uuid-v4",
        "metadata": {
            "name": "string",
            "mime": "string"
        },
        "thumbnails": [],
        "application_id": string,
        "upload_data": {
            "size": number,
            "chunks": number
        },
        "id": "uuid-v4",
        "updated_at": number,
        "created_at": number
  }
}
  

Upload with chunk

To upload a file in multiple chunk you must first initial the file itself, and then upload into the file.

The file initialization and following upload calls takes this parameters as a query string:

  • filename: string, file name

  • type: string, mime type for the file

  • total_chunks: number, total number of chunk to be uploaded

  • total_Size: number, sum of every chunk size (total file size)

  • chunk_number: number, current chunk uploaded, set it to undefined during file creation process.

  • thumbnail_sync: when set then backend will wait up to 10 seconds for the preview to be generated before to reply.

Upload a file with chunk

POST /internal/services/files/v1/companies/:company_id/files/?filename...

This route should first be called without data to initialise the entity for multi-chunk, then chunks must be sent on other route below

Overwrite a file

POST /internal/services/files/v1/companies/:company_id/files/:file_id/?totalChunks...

Overwrite a file (check user belongs to company) User can call this if the file was not already uploaded. If file already exist only apps can do this (users cannot directly overwrite a file).

Last updated