BucketManager

Provides methods for managing buckets in an S3 endpoint.

Constructor

new BucketManager(clientKey, clientSecret)

Creates a new instance of the constructor.

Parameters:
NameTypeDescription
clientKeystring

The access key ID for authentication.

clientSecretstring

The secret access key for authentication.

Tutorials
Example
import { BucketManager } from "@filebase/sdk";
const bucketManager = new BucketManager("KEY_FROM_DASHBOARD", "SECRET_FROM_DASHBOARD");

Methods

(async) create(name) → {Promise.<bucket>}

Creates a new bucket with the specified name.

Parameters:
NameTypeDescription
namestring

The name of the bucket to create.

Returns:
  • A promise that resolves when the bucket is created.
Type: 
Promise.<bucket>
Example
// Create bucket with name of `create-bucket-example`
await bucketManager.create(`create-bucket-example`);

(async) list() → {Promise.<Array.<bucket>>}

Lists the buckets in the client.

Returns:
  • A promise that resolves with an array of objects representing the buckets in the client.
Type: 
Promise.<Array.<bucket>>
Example
// List all buckets
await bucketManager.list();

(async) delete(name) → {Promise.<boolean>}

Deletes the specified bucket.

Parameters:
NameTypeDescription
namestring

The name of the bucket to delete.

Returns:
  • A promise that resolves when the bucket is deleted.
Type: 
Promise.<boolean>
Example
// Delete bucket with name of `bucket-name-to-delete`
await bucketManager.delete(`bucket-name-to-delete`);

(async) setPrivacy(name, targetState) → {Promise.<boolean>}

Sets the privacy of a given bucket.

Parameters:
NameTypeDescription
namestring

The name of the bucket to toggle.

targetStateboolean

The new target state. [true=private,false=public]

Returns:

A promise that resolves to true if the bucket was successfully toggled.

Type: 
Promise.<boolean>
Example
// Toggle bucket with label of `toggle-bucket-example`
await bucketManager.setPrivacy(`toggle-bucket-example`, true);  // Enabled
await bucketManager.setPrivacy(`toggle-bucket-example`, false); // Disabled

(async) getPrivacy(name) → {Promise.<boolean>}

Gets the privacy of a given bucket

Parameters:
NameTypeDescription
namestring

The name of the bucket to query.

Returns:

A promise that resolves to true if the bucket is private.

Type: 
Promise.<boolean>