Stack (file)

In an Akord vault, files and other assets are organized as 'stacks'. A stack represents one single file and all the subsequent revisions that may come after.

create(vaultId, file, options)

  • vaultId (string, required)

  • file (FileLike, required) - file object - web: File, node: NodeJs.File (Blob implementation; web like File)

  • options (StackCreateOptions, optional)

  • returns Promise<{ stackId, transactionId, uri }> - Promise with new stack id & corresponding transaction id

example
const { stackId } = await akord.stack.create(vaultId, "./photo.jpg");

See Next.js file upload showcase here

import(vaultId, fileTxId)

Create new stack from an existing arweave file transaction:

  • vaultId (string, required)

  • fileTxId (string, required) - arweave file transaction id reference

  • options (NodeCreateOptions, optional) - parent id, etc.

  • returns Promise<{ stackId, transactionId }> - Promise with new stack id & corresponding transaction id

example
const { stackId } = await akord.stack.import(vaultId, "kzGxbFW_oJ3PyYneRs9cPrChQ-k-8Fym5k9PCZNJ_HA");

rename(stackId, name)

  • stackId (string, required)

  • name (string, required) - new stack name

  • returns Promise<{ transactionId }> - Promise with corresponding transaction id

example

uploadRevision(stackId, file)

  • stackId (string, required)

  • file (FileLike, required) - file object

  • options (FileUploadOptions, optional)

  • returns Promise<{ transactionId }> - Promise with corresponding transaction id

example

revoke(stackId)

  • stackId (string, required)

  • returns Promise<{ transactionId }> - Promise with corresponding transaction id

example

move(stackId, parentId)

  • stackId (string, required)

  • parentId (string, required) - new parent folder id

  • returns Promise<{ transactionId }> - Promise with corresponding transaction id

example

restore(stackId)

  • stackId (string, required)

  • returns Promise<{ transactionId }> - Promise with corresponding transaction id

example

delete(stackId)

  • stackId (string, required)

  • returns Promise<{ transactionId }> - Promise with corresponding transaction id

example

get(stackId, options)

  • stackId (string, required)

  • options (GetOptions optional)

  • returns Promise<Stack> - Promise with the stack object

example

listAll(vaultId, options)

  • vaultId (string, required)

  • options (ListOptions, optional)

  • returns Promise<Array<Stack>> - Promise with all stacks within given vault

example

list(vaultId, options)

  • vaultId (string, required)

  • options (ListOptions, optional)

  • returns Promise<{ items, nextToken }> - Promise with paginated stacks within given vault

example

getVersion(stackId, index)

Get file stack version by index, return the latest version by default:

  • stackId (string, required)

  • index (number, optional) - file version index

  • returns Promise<{ name: string, data: ArrayBuffer }> - Promise with file name & data buffer

example

getUri(stackId, type, index)

Get stack file uri by index, return the latest arweave uri by default:

  • stackId (string, required)

  • type (StorageType, optional) - storage type, default to arweave

  • index (number, optional) - file version index, default to latest

  • returns Promise<string> - Promise with stack file uri

example

Last updated

Was this helpful?