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",
app_id: "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",
app_id: "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/?link_id=3c7d6e9ecb0a4ac9ab9aedfa0035232d";
const { data } = await boxClient.listObjectsFromLink({
fullLink: link,
});
The supported parameters are fullLink
, linkId
, page
and limit