uploadFolder()

Uploads a group of files to Irys in a single transaction.

Funding

Note
Note
Uploads of less than 100 KiB are free. For larger uploads, you'll need to fund your account first.

NodeJS

Parameters

NameTypeDescription
folderToUploadstringPath to the folder being uploaded.
indexFilestring(Optional) The name of an index file included in the folder. If provided, this file loads when accessing https://gateway.irys.xyz/:manifestId.
batchSizenumber(Optional) Number of files to upload simultaneously.
keepDeletedboolean(Optional) Whether to retain deleted items from previous uploads when re-uploading folders.

Returns

Returns a JSON object containing:

response = {
  id,              // Transaction ID for downloading data
  timestamp,       // UNIX milliseconds when transaction was created
  version,         // Currently 1.0.0
  public,          // Bundler node's public key
  signature,       // Signed deep hash of receipt
  deadlineHeight,  // Block number for finalization
  verify,          // Async function to verify receipt
}

Example

Note
Note
Use a token-specific version of getIrysUploader() to connect to an Irys Bundler before uploading. Choose one from the setup documentation.
const irys = await getIrysUploader();

const folderToUpload = "./my-images/";
try {
  const response = await irys.uploadFolder("./" + folderToUpload, {
    indexFile: "",
    batchSize: 50,
    keepDeleted: false,
  });

  console.log(`Files uploaded. Manifest ID ${response.id}`);
} catch (e) {
  console.log("Error uploading file ", e);
}

Browser

When uploading from the browser, pass an array of File objects.

Parameters

NameTypeDescription
filesTaggedFile[]Array of files to upload.
throwawayKeystring(Optional) JWK for signing multiple upload sets.
indexFileRelPathstring(Optional) Relative path like folder/index.html.
separateManifestTxboolean(Optional) Excludes manifest from bundle for indexability.
manifestTagsTag[](Optional) Tags for manifest transaction.

Returns

Returns a JSON object containing:

response = {
  id,              // Manifest ID
  timestamp,       // Creation timestamp in UNIX milliseconds
  version,         // Currently 1.0.0
  public,          // Bundler's public key
  signature,       // Signed receipt hash
  deadlineHeight,  // Block finalization deadline
  verify,          // Receipt verification function
}

Example

const irysUploader = await getIrysUploader();

const files: File[] = [];
const tags: { name: string; value: string }[][] = [];

const taggedFiles = files.map((f: TaggedFile, i: number) => {
  f.tags = tags[i];
  return f;
});

const uploadOptions = {
  indexFileRelPath: "./index.html",
  manifestTags: myTags,
  throwawayKey: myKey,
  seperateManifestTx: true,
};
const response = await irysUploader.uploadFolder(taggedFiles, uploadOptions);

Downloading

Files are retrievable using the following URL formats:

  • By manifest and file name
  • By transaction ID
Info
Info
After upload completion, two files are generated locally: [folder_name].csv and [folder_name].json, containing transaction IDs for each uploaded file.