Files

This document contains endpoints for

  1. Uploading files to different parts of the app

  2. Files feature in the projects

Uploading and Downloading

Files can be uploaded to tasks, task activities, chat messages, clients, and the files page. For all of these operations, first, you need to send a request to upload the file. After the upload completes, the server will return the id of the file. Then, you can use this id in other API endpoints.

Upload File

POST https://cubicl.io/api/v1/files/upload

Uploads a file to use later. Returns the details of the saved file.

Unlike other API endpoints, this endpoint accepts a multipart/form-data request. The Content-Length header must be set to the size of the form data.

Files up to 4GB (4 million KB) in size are supported.

Request Body

NameTypeDescription

file

blob

File content and file name.

File

GET https://cubicl.io/api/v1/files/:id/url

Files uploaded to Cubicl cannot be accessed without authorization. In order to download a file, you need to request a download link. Then, you can send an HTTP request to the returned link to download the file. Links have a 5-minute lifetime. After that, you need to get another link.

Path Parameters

NameTypeDescription

id*

string

File id

string

Files Page Endpoints

These endpoints allow you to view, create, edit and delete files and folders in the Files page of a project and a client.

Cubicl allows you to organize files and directories for both projects and also clients.

The structure of the Files page is similar to the file system in a computer or other file storage services such as Google Drive. It consists of nested file and directory nodes. At the top, a root directory node exists. Directories hold child file and directory nodes. File nodes are not same as the file record returned from Upload File endpoint. File node records point to file records.

Get Nodes

GET https://cubicl.io/api/v1/file-system-nodes

Gets file and directory nodes in a directory. The request should be sent with either 'group' or 'customer' parameters.

Query Parameters

NameTypeDescription

group

string

Project id

customer

string

Client id

parent

string

Id of the directory to search.

Use 'null' for root directory.

If not given, will search in all directories.

search

string

Will be searched in file and directory names

FileSystemNode[]

Create Files

POST https://cubicl.io/api/v1/file-system-nodes/files

Creates file nodes for uploaded files.

Files can be create in either a project's or client's files page. Either group or customer parameter must be set.

Request Body

NameTypeDescription

group

string

Project id if file is being created in a project's files page

customer

string

Client id if file is being created in a client's files page

parent*

string | null

Parent directory id

null if parent is the root directory

files*

string[]

File id list

FileSystemNode[]

Create Directory

POST https://cubicl.io/api/v1/file-system-nodes/directories

Creates a directory node.

Files can be created on either a project's or a client's files page. Either group or customer parameters must be set.

Request Body

NameTypeDescription

group

string

Project id if directory is being created in a project's files page

customer

string

Client id if directory is being created in a client's files page

parent*

string | null

Parent directory id

null if parent is the root directory

name*

string

Directory name

FileSystemNode

Delete Nodes

DELETE https://cubicl.io/api/v1/file-system-nodes

Deletes file and directory nodes from a project or a client.

File nodes are deleted together with the file records and the uploaded file. Multiple nodes from different projects or clients cannot be deleted in a single request.

Request Body

NameTypeDescription

nodes*

string[]

Node id list

Data

File

type File = {
    _id: string;
    name: string;
    thumbnail?: string; // Link to thumbnail URL if file is a supported image
    // If file is attached from Google Drive
    google?: {
        id: string;
        extension: string;
        webViewLink: string;
        mimeType: string;
    },
    // If file is attached from Dropbox
    dropbox?: {
        id: string;
        webViewLink: string;
    }
}

File System Node

type FileSystemNode = {
    _id : string;
    // Parent directory id. null when parent is the root directory
    parent: string | null;
    group?: string; // Project id
    customer?: string; // Cliend id
    type: 'f' | 'd'; // f for file, d for directory
    file: File | null; // File when type is 'f', null when type is 'd'
    // Set when type is 'd'. If type is 'f', get name from 'file' property.
    name?: string;
    createdAt: number;
}

Last updated