Skip to main content

ThirdwebStorage.uploadBatch() method

Batch upload arbitrary file or JSON data using the configured decentralized storage system. Automatically uploads any file data within JSON objects and replaces them with hashes.

Signature:

uploadBatch(data: unknown[], options?: T): Promise<string[]>;

Parameters

ParameterTypeDescription
dataunknown[]Array of arbitrary file or JSON data to upload
optionsT(Optional) Options to pass through to the storage uploader class

Returns:

Promise<string[]>

  • The URIs of the uploaded data

Example

// Upload an array of file data
const files = [readFileSync("../file1.jpg"), readFileSync("../file2.jpg")];
const fileUris = await storage.uploadBatch(files);

// Upload an array of JSON objects
const objects = [
{ name: "JSON 1", image: files[0] },
{ name: "JSON 2", image: files[1] },
];
const jsonUris = await storage.uploadBatch(objects);