CTW BOX - Core SDK
The following is the NodeJS implementation of the SDK APIs for CTW BOX
Goal
Having a component that can be integrated in other applications to use features from ctw-box like:
- Searching for object
- Retrieving objects with permanent links
- Upoading new objects
Setup
import BoxClient from "@g123jp/box-client";
const boxClient = new BoxClient({
endpoint: "https://ctwbox.stg.g123.jp",
accessToken: "...",
});
File Upload
The following is an example of usage for uploading a file to CTW BOX with some parameters like
- Category
- Project
- Attributes
Other parameters are not necessary and identified by the method, like
- Owner: already identified by the access token
- File Size: from file
- Mime Type: from file
- File Name: from file if not set
const options = {
category: "icon",
project: "auo",
attributes: {
style: "round",
isTemplate: true,
},
};
const { object_id } = await boxClient.fPutObject(file, metadata);
Search
The search operation would be performed as follows
const options = {
category: "icon",
project: "auo",
text: "image_02",
searchType: "tag",
};
const { data } = await boxClient.listObjects(options);
Retrieve with permanent link
With this operation, it is possibile to retrieve all the objects uploaded in a speciffic batch given the permanent URL
const link =
"https://ctwbox.stg.g123.jp/?owner=lukasz.m&updated_at_range=1672996870_1672996881&page=1";
const { data } = await boxClient.listObjectsFromLink(options);