Akord docs
  • Introduction
    • 👋About Akord
    • 🌇Akord–Arweave Sunsetting FAQs
    • Page
  • API & DEV TOOLS
    • 🕺Simple API upload
    • 🤓Learn
      • Akord protocol
        • Tags
        • Vault
          • Fields
          • Functions
            • vault:init
            • vault:update
            • vault:archive
            • vault:restore
        • Membership
          • Fields
          • Functions
            • membership:invite
            • membership:accept
            • membership:reject
            • membership:revoke
            • membership:change-role
            • membership:update
        • Node
          • Fields
          • Functions
            • node:create
            • node:update
            • node:move
            • node:revoke
            • node:restore
            • node:delete
      • Publishing a website
        • Troubleshooting website publishing
      • Technical Litepaper
      • End-to-end encryption
      • Bundling
    • 🏗️Build
      • REST API
        • Authentication
        • Rate limits
        • Timeouts
        • Webhooks
        • Examples
          • Simple uploads
          • Multipart uploads
      • SDK – AkordJS
        • Usage
        • Modules
          • Auth
          • Vault
          • Membership
          • Folder
          • Stack (file)
          • Manifest
          • Note
          • Memo (message)
          • Batch
        • Examples
      • CLI
        • Quick start
        • Login
        • Vaults
        • Files and stacks
        • Memos / messages
        • Folders
        • Memberships
      • Arweave Gateway – AKRD
  • App
    • 💻Product guides
      • Signing up
        • Akord Wallet
        • Recovery phrase explained
      • Akord Vaults
        • Vault types explained
        • Creating a vault
        • Vault info
      • File management
        • Uploading files
        • File info
        • Sort/filter, folders & batch actions
        • File versioning
      • Add manifest
      • Sharing files
      • Media gallery
      • Invites
      • Messaging
      • Notes
      • Timeline
      • Storage
        • Monitoring usage
        • Top ups
        • Blockchain transactions
      • Account
        • Reveal recovery phrase
        • Change password
        • Account deletion
Powered by GitBook
On this page

Was this helpful?

  1. API & DEV TOOLS
  2. Build
  3. SDK – AkordJS
  4. Modules

Stack (file)

Last updated 1 year ago

Was this helpful?

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 (, 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");

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
const { transactionId } = await akord.stack.rename(stackId, "new name for your stack");

uploadRevision(stackId, file)

  • stackId (string, required)

  • options (FileUploadOptions, optional)

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

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

revoke(stackId)

  • stackId (string, required)

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

example
const { transactionId } = await akord.stack.revoke(stackId);

move(stackId, parentId)

  • stackId (string, required)

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

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

example
// create new folder
const { folderId } = await akord.folder.create(vaultId, "new folder");
// move the stack to newly created folder
const { transactionId } = await akord.stack.move(stackId, folderId);

restore(stackId)

  • stackId (string, required)

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

example
const { transactionId } = await akord.stack.restore(stackId);

delete(stackId)

  • stackId (string, required)

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

example
const { transactionId } = await akord.stack.delete(stackId);

get(stackId, options)

  • stackId (string, required)

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

example
const stack = await akord.stack.get(stackId);

listAll(vaultId, options)

  • vaultId (string, required)

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

example
const stacks = await akord.stack.listAll(vaultId);

list(vaultId, options)

  • vaultId (string, required)

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

example
// retrieve first 100 stacks for the vault
const { items } = await akord.stack.list(vaultId);

// retrieve first 20 stacks for the vault
const { items } = await akord.stack.list(vaultId, { limit: 20 });

// iterate through all stacks
let token = null;
let stacks = [];
do {
  const { items, nextToken } = await akord.stack.list(vaultId, { nextToken: token });
  stacks = stacks.concat(items);
  token = nextToken;
} while (token);

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
// get the latest stack version
const { name: fileName, data: fileBuffer } = await akord.stack.getVersion(stackId);

// get the first stack version
const { name: fileName, data: fileBuffer } = await akord.stack.getVersion(stackId, 0);

getUri(stackId, type, index)

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

  • stackId (string, required)

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

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

example
// get the arweave uri for the latest file version
const arweaveUri = await akord.stack.getUri(stackId);

// get the arweave uri for the first file version
const arweaveUri = await akord.stack.getUri(stackId, 0);

file (, required) - file object

options ( optional)

options (, optional)

options (, optional)

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

🏗️
FileLike
See Next.js file upload showcase here
FileLike
GetOptions
ListOptions
ListOptions
StorageType