PinManager

Provides methods for managing pins in an REST endpoint.

Constructor

new PinManager(clientKey, clientSecret, optionsopt)

Creates a new instance of the constructor.

Parameters:
NameTypeAttributesDescription
clientKeystring

The access key ID for authentication.

clientSecretstring

The secret access key for authentication.

optionspinManagerOptions<optional>

Optional settings for the constructor.

Tutorials
Example
import { PinManager } from "@filebase/sdk";
const pinManager = new PinManager("KEY_FROM_DASHBOARD", "SECRET_FROM_DASHBOARD", {
  bucket: "my-default-bucket",
  gateway: {
    endpoint: "https://my-default-gateway.mydomain.com
    token: SUPER_SECRET_GATEWAY_TOKEN
  }
});

Methods

(async) list(listOptionsopt, optionsopt) → {Promise.<listPinResults>}

List the pins in a given bucket

Parameters:
NameTypeAttributesDescription
listOptionslistPinOptions<optional>
optionspinOptions<optional>
Returns:
Type: 
Promise.<listPinResults>
Example
// List pins in bucket with a limit of 1000
await pinManager.list({
  limit: 1000
});

(async) create(key, cid, metadataopt, optionsopt) → {Promise.<pinStatus>}

Create a pin in the selected bucket

Parameters:
NameTypeAttributesDescription
keystring

Key or path of the file in the bucket

cidstring

Content Identifier (CID) to be pinned recursively

metadataObject<optional>

Optional metadata for pin object

optionspinOptions<optional>

Options for pinning the object

Returns:
Type: 
Promise.<pinStatus>
Example
// Create Pin with Metadata
await pinManager.create("my-pin", "QmTJkc7crTuPG7xRmCQSz1yioBpCW3juFBtJPXhQfdCqGF", {
  "application": "my-custom-app-on-filebase"
});

(async) replace(requestid, cid, optionsopt) → {Promise.<pinStatus>}

Replace a pinned object in the selected bucket

Parameters:
NameTypeAttributesDescription
requestidstring

Unique ID for the pinned object

cidstring

Content Identifier (CID) to be pinned recursively

optionsreplacePinOptions<optional>

Options for pinning the object

Returns:
Type: 
Promise.<pinStatus>
Example
// Replace Pin with Metadata
await pinManager.create("qr4231213", "QmTJkc7crTuPG7xRmCQSz1yioBpCW3juFBtJPXhQfdCqGF", {
  "revision": Date.now()
}

(async) download(cid, optionsopt) → {Promise.<stream>}

Download a pin from the selected IPFS gateway

Parameters:
NameTypeAttributesDescription
cidstring
optionspinDownloadOptions<optional>
Returns:
Type: 
Promise.<stream>
Example
// Download Pin by CID
await pinManager.download("QmTJkc7crTuPG7xRmCQSz1yioBpCW3juFBtJPXhQfdCqGF");

(async) get(requestid, optionsopt) → {Promise.<(pinStatus|false)>}

Get details about a pinned object

Parameters:
NameTypeAttributesDescription
requestidstring

Globally unique identifier of the pin request

optionspinOptions<optional>

Options for getting the pin

Returns:
Type: 
Promise.<(pinStatus|false)>
Example
// Get Pin Info by RequestId
await pinManager.get("qr4231214");

(async) delete(requestid, optionsopt) → {Promise.<boolean>}

Delete a pinned object from the selected bucket

Parameters:
NameTypeAttributesDescription
requestid

Globally unique identifier of the pin request

optionspinOptions<optional>

Options for deleting the pin

Returns:
Type: 
Promise.<boolean>
Example
// Delete Pin by RequestId
await pinManager.delete("qr4231213");