Getting Started

You can interact with binsta programmatically through the javascript client. First install it in your project using npm or yarn.

Next, you'll want to and initialize a binsta client on your server (be sure to keep your access token secret).

Upload a file

Uploading a file is a multistep process. To begin the process, you'll first need to create the metadata for the file.

Create the file metadata

The function to create a file accepts two optional parameters, name and folder_id. If you do not pass a folder_id, the file will automatically be placed in your root folder.

repsonse.json

Create a signed upload URL

Next, you'll need to create a signed upload url. The signed url is a special url that anyone can use to upload a file, but it is secure in that it expires after 1 minute. It's important that you generate the signed url server-side so that you don't expose your access token to your end users.

Once you've generated the signed url, you can use it to upload a file from the server or from the browser.

Upload from the browser

If you would like to upload the file directly from the browser, then you'll need to create another binsta client in the browser and use the signed upload url that you generated server-side to upload the file. Below illustrates how you might tie all of this together.

server

browser

Upload from the server

Alternatively, if you'd like to upload a file directly from the server or in a node script, then you can do something like below.

server

Get a file

To get the metadata for a file, you can fetch it by its id.

repsonse.json

Create a folder

Creates a new folder. This function accepts two optional parameters, name and folder_id. If you do not pass a folder_id, the new folder will automatically be created in the root folder.

repsonse.json

Get a folder

To get the metadata for a folder, you can fetch it by its id.

repsonse.json