Constructor
new BucketManager(clientKey, clientSecret)
Creates a new instance of the constructor.
Name | Type | Description |
---|---|---|
clientKey | string | The access key ID for authentication. |
clientSecret | string | The secret access key for authentication. |
- Source
- Tutorials
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.
Name | Type | Description |
---|---|---|
name | string | The name of the bucket to create. |
- Source
- A promise that resolves when the bucket is created.
- Type:
- Promise.<bucket>
// 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.
- Source
- A promise that resolves with an array of objects representing the buckets in the client.
- Type:
- Promise.<Array.<bucket>>
// List all buckets
await bucketManager.list();
(async) delete(name) → {Promise.<boolean>}
Deletes the specified bucket.
Name | Type | Description |
---|---|---|
name | string | The name of the bucket to delete. |
- Source
- A promise that resolves when the bucket is deleted.
- Type:
- Promise.<boolean>
// 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.
Name | Type | Description |
---|---|---|
name | string | The name of the bucket to toggle. |
targetState | boolean | The new target state. [true=private,false=public] |
- Source
A promise that resolves to true if the bucket was successfully toggled.
- Type:
- Promise.<boolean>
// 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
Name | Type | Description |
---|---|---|
name | string | The name of the bucket to query. |
- Source
A promise that resolves to true if the bucket is private.
- Type:
- Promise.<boolean>
(async) generateCid(name) → {Promise.<boolean>}
Generates the IPFS Directory/Folder CID for a given bucket
Name | Type | Description |
---|---|---|
name | string | The name of the bucket to use. |
- Source
A promise that resolves with the CID of the new directory/folder
- Type:
- Promise.<boolean>