node-fullbox-api
$3
This is a full cycle implementation of the Box API. It includes:
* Box Token Request
* Box Refresh Token Request
* Upload file to box
* Retrieve Box file information
* Shared link creation
* Retrieve file from Box
* Retrieve thumbnail of file from Box
More api intergration to come.
Future enhancements include using the Box View Api to generate thumbnails for more file types, and integration with the Box View API.
Installation
npm install node-fullbox-api
Setup and Use
var BOX = require('node-fullbox-api');
var Box = new BOX(box_options);
Box Options
{
authorize_url :
,
token_url : ,
user_name : ,
password : ,
client_id : ,
client_secret : ,
base_url: ,
upload_url: ,
auto_rename : (auto-renaming uploaded files in the case of name collisions)
}
$3
All of the functions first check for a valid token. If one is not found it first tries to refresh the last token, otherwise makes a request for a new token.
Box.uploadfile(values, callback);
Function to upload a file to Box. The JSON returned is identical to the JSON the standard API returns.
Values
{
filename : ,
folderid : ,
filepath :
}
Callback
function(data) {
/ data is the json data returned for the box file /
}
Box.getfileinfo(values, callback);
Function to get file information from Box. The JSON returned is identical to the JSON the standard API returns.
Values
{
fileid :
}
Callback
function(data) {
/ data is the json data returned for the box file /
}
Box.createsharedlink(values, callback);
Creates a shared link for a box file. The JSON returned is identical to the JSON the standard API returns.
Values
{
fileid : ,
access : , / open, company, collaborators, null (default is open, null removes shared link) /
can_download : / determines of downloads of file is available /
}
Callback
function(data) {
/ data is the json data returned for the box file /
}
Box.getthumbnail(values);
Returns a stream of the image thumbnail for a file in box. If the file is an image or movie type a thumbnail will be returned. If not an image or movie, the file type icon from box will be returned, otherwise a generic default image is returned.
Values
{
fileid : ,
response_stream :
}