Code Monkey home page Code Monkey logo

node-box's Introduction

Box API Node.JS Client

Install

npm install nodejs-box

Setup

First, you need to go through the OAuth2 process with Box.com, so that you can receive an access token. I recommend the box-passport module to help with this.

var Box = require('nodejs-box');

var box = new Box({
  access_token: 'YOUR_ACCESS_TOKEN_GOES_HERE',
  refreh_token: 'YOUR_REFRESH_TOKEN_GOES_HERE'
});

Example Usage

Working with files

Once you've creted a Box instance (see above section) you can act on file resources by calling functions on box.files.

Uploading a file

There are two ways to upload a file:

  • If the file has a custom filename

box.files.upload(filepath, filename, folderId, callback);

  • If the file does not have a custom filename

box.files.upload(filepath, folderId, callback);

Create and view information about a file

Get information about a file:

box.files.info(fileId, fields, callback);

Create metadata for a file:

box.files.createMetadata(fileId, metadata, callback);

Get all metadata for a file

box.files.getAllMetadata(fileId, callback);

Get specific metadata for a file. The path parameter is a combination of the scope and template attributes on the Box.com api, so will look like enterprise/marketingCollateral. For more detail, see the Box.com api docs

box.files.getMetadata(fileId, path, callback);

Download links

There are two ways to get a download link for a file:

  • Retrieve a download link for the given file without a shared item:

box.files.download(fileId, callback);

  • Retrieve a download link for the given file from a shared item:

box.files.download(fileId, shareLink, callback);

Creating a shared link

Create a shared link:

box.files.createSharedLink(file, sharedLinkSettings, callback);

UPDATED README COMING SOON

node-box's People

Contributors

dremonkey avatar fatshotty avatar lyaunzbe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.