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 an object with the following value:

response = {
  id,              // Transaction ID for downloading data
}

The response also carries the fields of the legacy receipt object. They are kept for backwards compatibility, are not documented, and should not be relied on.

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 an object with the following value:

response = {
  id,              // Manifest ID
}

The response also carries the fields of the legacy receipt object. They are kept for backwards compatibility, are not documented, and should not be relied on.

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,
  separateManifestTx: 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.