Skip to main content

Uploading A Folder

You can batch upload an entire folder of files all at once using the function bundlr.uploadFolder(pathToFolder+folderName). The function returns a manifest id which can be used to retrieve uploaded data.

The function takes one required parameter pointing to the folder to be uploaded along with three optional parameters.

  1. indexFile: The name of an index file also included in the folder you upload. If provided, this index file will load when a user requests[manifest_id]
  2. batchSize: The number of files to upload at once.
  3. keepDeleted: Whether to keep now deleted items from previous uploads. When you upload a folder, the file names are indexed and saved. If you then re-upload that same folder, Bundlr will only upload new files added since the previous upload. In the case where you delete files from your source directory, this flag tells Bundlr whether to keep those deleted files in the index or remove them.
// Upload an entire folder
// More llamas for you to upload ... or change to your own files
// Upload some NFTs, your vacation photos or your band's latest album.
const folderToUpload = "llama_folder";
try {
const response = await bundlr.uploadFolder("./" + folderToUpload, {
indexFile: "", // optional index file (file the user will load when accessing the manifest)
batchSize: 50, //number of items to upload at once
keepDeleted: false, // whether to keep now deleted items from previous uploads
}); //returns the manifest ID

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

Files uploaded via bundlr.uploadFolder(pathToFolder+folderName) can be retrieved in one of two ways.

  1. Creating an URL with the format[manifed_id]/[original_file_name].
  2. Creating an URL using the transaction ID of each individual file uploaded with the format[transacton_id]

After a successful folder upload, two files are written to your local project directory [folder_name].csv and [folder_name].json. The example below highlights a folder called “llama_folder” with a total of 5 files in it. The transaction id for each file can be used to retrieve the uploaded data by forming an URL with the format]/[transaction_id]