File Management Service

Trillo Workbench provides a restful file management service and SFTP. In addition to it, it provides a complete application for files management including its UI.

Architecture

The following diagram shows file management related components of Trillo Workbench.

  1. Trillo Workbench provides a restful service to upload, download files. It also provides APIs to delete, move, copy files and folders.

  2. Trillo Workbench incorporates a SFTP server for file transfer.

  3. Trillo Workbench database caches the folders and files hierarchy for logical views and high performance.

  4. Access control rules (RBAC) are stored in the Trillo WOrkbench Database.

Trillo File Manager

Trillo File Manager is complete product, including UI, for managing files stored on the cloud storage buckets. It is a part of the Trillo Workbench, and also available as a standalone product. It is similar to DropBox or Box. It features:

  • Folders and files management using UI. A few examples are as follows:

    • Create folder hierarchy.

    • Upload one or more files.

    • Move, copy, delete, and rename files.

    • Versioning of files.

    • Sharing of files.

    • Download one or more files.

  • SFTP (secure using public/private key pairs).

  • APIs for file transfer and managing folders and files (move, delete, rename, copy, paste, etc.)

See the document Trillo File Manager Documentation for more details of the Trillo File Manager.

Folder Service APIs

The internal service that supports file management APIs is called Folder Service. This section discusses a few examples of its APIs.

File Upload APIs

Uploading a file to cloud storage bucket uses more than one APIs. The are listed in the order of the control flow. Each API assumes that access token is passed as Authorization header.

  1. Retrieve Signed URL (for upload).

  2. Upload File Using Signed URL - using multipart mime.

  3. Save File Object - it creates a record for the uploaded file in the database (for caching and access control rules).

Example APIs for each of the above steps are shown below.

Retrieve Upload Signed URL

End-point:

POST /foldersvc/cloudstorage/folder/retieveSignedUrl

Body:

{
   “folderName” : <cloud storage bucket folder>,
   "subFolder":  "<sub folder if any>",
   “contentType” :<file content type>,
   “fileName” : “<name of the file to be uploaded>,
   “method”: “PUT”
}

The parameter “method”: “PUT” instructs Cloud Storage Service to create 
a signed url for uplaod.

Response:

{
    “code”: 200,
    “data: {
       “signedUrl” : “value of signed URL”
    }
}

Upload File Using Signed URL

End-point:

PUT <signed url value>

Header:

'Content-Type': 'multipart/formdata; charset=UTF-8'

Body:

{
   actual file
}

Response:

Returns HTTP code 200 if successful. No body is returned.

Save File Object

This API creates a database record corresponding to the file.

End-point:

POST /foldersvc/cloudstorage/folder/saveObject

Body:

{
   “folderName” : <cloud storage bucket folder>,
   "subFolder":  "<sub folder if any>",
   “contentType” :<file content type>,
   “fileName” : “<name of the file to be uploaded>,
   "provider": "cloudstorage"
}

Response: It returns the file object created in the database as JSON. An example is shown below.

{
   "fileName":"TrillWorkbench-Database-Tabs.png",
   "folderName":"/users/test201/Home/tmp",
   ...
   "folderId":84,
   "size":79336,
   "contentType":"image/png",
   "fileType":"png",
   "idOfUser":3,
   "userId":"test201",
   ...
   "topFolderId":82,
   "createdAt":1615795228850,
   ...
   "updatedAt":1615795228850,
   "versionsCount":0,
   "id":444
}

File Download API

A client obtains a signed URL to download a file from the bucket.

Retrieve Download Signed URL

Endpoint:

POST /foldersvc/cloudstorage/folder/retieveSignedUrl

Body:

{
   “folderName” : <cloud storage bucket folder>,
   “contentType” :<file content type>,
   “fileName” : “<name of the file to be downloaded>,
   "fileId": "<databse id of the file>",
   “method”: “GET”
}
The parameter “method”: “GET” instructs Cloud Storage Service to create 
a signed url for download.

Response:

{
    “code”: 200,
    “data: {
       “signedUrl”: “value of signed URL”
    }
}

Downloading FIle

A client such as browser can download the file using a signed URL.

Other APIs

We discussed file upload and download APIs above. They provide file transfer feature using HTTPs. In addition to these APIs, there are other APIs to perform operations on folders and files - such as rename, delete, copy, paste, delete, etc. Refer to APIs reference guide for the details of these APIs.

Last updated