Constructor
new PinManager(clientKey, clientSecret, optionsopt)
Creates a new instance of the constructor.
Name | Type | Attributes | Description |
---|---|---|---|
clientKey | string | The access key ID for authentication. | |
clientSecret | string | The secret access key for authentication. | |
options | pinManagerOptions | <optional> | Optional settings for the constructor. |
- Source
- Tutorials
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
Name | Type | Attributes | Description |
---|---|---|---|
listOptions | listPinOptions | <optional> | |
options | pinOptions | <optional> |
- Source
- Type:
- Promise.<listPinResults>
// 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
Name | Type | Attributes | Description |
---|---|---|---|
key | string | Key or path of the file in the bucket | |
cid | string | Content Identifier (CID) to be pinned recursively | |
metadata | Object | <optional> | Optional metadata for pin object |
options | pinOptions | <optional> | Options for pinning the object |
- Source
- Type:
- Promise.<pinStatus>
// 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
Name | Type | Attributes | Description |
---|---|---|---|
requestid | string | Unique ID for the pinned object | |
cid | string | Content Identifier (CID) to be pinned recursively | |
options | replacePinOptions | <optional> | Options for pinning the object |
- Source
- Type:
- Promise.<pinStatus>
// 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
Name | Type | Attributes | Description |
---|---|---|---|
cid | string | ||
options | pinDownloadOptions | <optional> |
- Source
- Type:
- Promise.<stream>
// Download Pin by CID
await pinManager.download("QmTJkc7crTuPG7xRmCQSz1yioBpCW3juFBtJPXhQfdCqGF");
(async) get(requestid, optionsopt) → {Promise.<(pinStatus|false)>}
Get details about a pinned object
Name | Type | Attributes | Description |
---|---|---|---|
requestid | string | Globally unique identifier of the pin request | |
options | pinOptions | <optional> | Options for getting the pin |
- Source
- Type:
- Promise.<(pinStatus|false)>
// Get Pin Info by RequestId
await pinManager.get("qr4231214");
(async) delete(requestid, optionsopt) → {Promise.<boolean>}
Delete a pinned object from the selected bucket
Name | Type | Attributes | Description |
---|---|---|---|
requestid | Globally unique identifier of the pin request | ||
options | pinOptions | <optional> | Options for deleting the pin |
- Source
- Type:
- Promise.<boolean>
// Delete Pin by RequestId
await pinManager.delete("qr4231213");