Twake
⬅️ Go on twake
  • ☀️ Twake
  • Getting started
    • ▶️Use Twake on twake.app
    • 🏗️Install on your server
      • 🎡Scale with Twake
    • ⚙️Configuration
      • 🔒Security
      • 🔗Custom domain + HTTPS
        • Apache2 configuration
      • 💌Configure mail server
      • 🎨Customisation
      • 🔌Connectors and plugins
      • 👨‍💻 Authentication modes
        • Using Keycloak (LDAP, OpenID and more)
        • Installing Twake with LemonLDAP (LDAP, OpenID and more)
  • How to use it
    • 👋Welcome to Twake !
    • 🧰Console
      • Users
    • 🏢Company & workspace
      • Invite user from Chat
      • Rights
    • 💠Applications
      • 💬Chat
        • Channels
        • Message
      • 📂Drive
        • File and folder
        • Share file with public link
      • 📆Calendar
      • ✅Tasks
      • 🔃Connectors
        • n8n
    • 🖥️Desktop and mobile app
    • 🔒Privacy
  • Developers API
    • 🏠Home
    • 🥇Getting started
      • Create your first application
      • Authenticate with Postman
      • Send a message with your application
      • Trigger action from command
    • ⚙️Application settings
      • Api
      • Display
      • Privileges
      • Identity
    • 📖API Reference
      • Webhook
      • Drive
      • Message
        • DELETE Request
        • POST Request
      • Authentication
    • 🧱Blocks
  • Internal Documentation
    • 🥇Get started
    • 🎨Twake Ecosystem Guidelines
    • 📚Our stack
    • 🧱Backend and APIs
      • 🔑(WIP) Authentication
      • 👥Users and workspaces
      • 🍎Applications
        • Database models
        • REST APIs
      • 🎩Channels and tabs
        • Database models
      • 💬Messages
        • Database models
      • 📄Files
        • Database models
        • REST APIs
        • Resumable.js
      • 📲Notifications
        • Database models
      • 🛠️Twake service development
        • What is a service in Twake ?
        • Create a new service
        • Platform/Technical services
          • Database ORM platform service
    • 🖥️Web, desktop and mobile
      • Table
      • ObjectModal
        • ObjectModalTitle
        • ObjectModalSeparator
        • ObjectModalSectionTitle
        • ObjectModalFormTitle
      • UserListManager
      • MediumPopupManager
      • MenuManager
    • 🎭Translation
Powered by GitBook
On this page
  • General
  • Get file metadata (check user belongs to comapny)
  • Download a file
  • Download thumbnails
  • Delete a file
  • Classic upload
  • Upload a file
  • Upload with chunk
  • Upload a file with chunk
  • Overwrite a file

Was this helpful?

  1. Internal Documentation
  2. Backend and APIs
  3. Files

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

Name
Type
Description

thumbnail_sync

boolean

Request Body

Name
Type
Description

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).

PreviousDatabase modelsNextResumable.js

Last updated 3 years ago

Was this helpful?

🧱
📄