On this page

Tigris Storage SDK provides a simple interface and minimal configuration that lets you get started quickly and integrate Tigris into your application. It is built on top of Tigris Object Storage API and offers all the functionality of Tigris.

## Use Cases

Tigris Storage SDK is geared (but not limited to) towards application developers who need to store objects that:

- Are programmatically uploaded or generated at build time, for display and download such as avatars, screenshots, cover images and videos
- Are larger and not practical to store in the database, such as images, videos, documents, etc.
- That needs to be retrieved frequently across different regions

## Getting Started

Getting started with Tigris Storage SDK is easy. First, you need to create a Tigris account and create a bucket.

### Setting up your account and bucket

1. Create a Tigris account at [storage.new](https://storage.new/)
2. Create a bucket at [console.storage.dev/createbucket](https://console.storage.dev/createbucket?pid=019f7240-083d-7830-9af1-acb2fbcbd4ec&sid=019f7240-0841-794b-a6af-f00397473c14)
3. Create an access key at [console.storage.dev/createaccesskey](https://console.storage.dev/createaccesskey?pid=019f7240-083d-7830-9af1-acb2fbcbd4ec&sid=019f7240-0841-794b-a6af-f00397473c14)

### Configure your Project

In your project root, create a `.env` file if it doesn't exist already and put the following content in it. Replace the values with actual values you obtained from above steps.

```bash
TIGRIS_STORAGE_ACCESS_KEY_ID=tid_access_key_id

TIGRIS_STORAGE_SECRET_ACCESS_KEY=tsec_secret_access_key

TIGRIS_STORAGE_BUCKET=bucket_name
```

### Installation

- NPM
- Yarn

```bash
npm install @tigrisdata/storage
```

```bash
yarn add @tigrisdata/storage
```

And this is it, you can now use the SDK in your application. Tigris Storage SDK supports both CommonJS and ES6 Modules syntax. That means you can use both `require` and `import` statements to use the SDK.

- ES6 Modules
- CommonJS Modules

```js
import { list } from "@tigrisdata/storage";

const objects = await list(); // lists objects in bucket TIGRIS_STORAGE_BUCKET

console.log(objects);
```

```js
const { list } = require("@tigrisdata/storage");

list().then((objects) => {

console.log(objects);
});
```

## Uploading Objects

You can upload objects to a bucket using the `put` function. You can also upload large objects using the `multipart` option. You can also track the upload progress using the `onUploadProgress` option.

```ts
// Simple upload
await put("object.txt", "Hello, World!");

// Uploading a file
await put("object.txt", file);

// Uploading a large object
await put("object.txt", file, { multipart: true });

// Uploading a large object with progress
await put("object.txt", file, {

multipart: true,

onUploadProgress: ({ loaded, total, percentage }) => {

console.log(`Uploaded ${loaded} of ${total} bytes (${percentage}%)`);

},

});
```

You can read more about uploading objects [here](/content/docs/sdks/tigris/using-sdk/#uploading-an-object/index.html).

## Downloading Objects

You can download objects from a bucket using the `get` function.

```ts
// Get a file as string
await get("object.json", "string");

// Get a object as File
await get("my-file.jpg", "file");

// Stream an object
await get("video.mp4", "stream", {

contentType: "video/mp4",

});

// Trigger a download
await get("object.txt", "file", {

contentDisposition: "attachment",

});
```

You can read more about downloading objects [here](/content/docs/sdks/tigris/using-sdk/#downloading-an-object/index.html).

## Further Resources

- [Using the SDK](/content/docs/sdks/tigris/using-sdk/index.html)
- [Client Uploads](/content/docs/sdks/tigris/client-uploads/index.html)
- [Examples](/content/docs/sdks/tigris/examples/index.html)
