ThirdwebStorage
class ThirdwebStorage<
function constructor<
Downloads arbitrary data from any URL scheme.
const uri = "ipfs://example";const data = await storage.download(uri);
function download( url: string,): Promise<Response>;
Downloads JSON data from any URL scheme. Resolves any URLs with schemes to retrievable gateway URLs.
const uri = "ipfs://example";const json = await storage.downloadJSON(uri);
function downloadJSON<TJSON = any>( url: string,): Promise<TJSON>;
Resolve any scheme on a URL to get a retrievable URL for the data
const uri = "ipfs://example";const url = storage.resolveScheme(uri);console.log(url);
function resolveScheme(url: string): string;
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.
// Upload an imagelaunchImageLibrary({ mediaType: "photo" }, async (response) => { if (response.assets?.[0]) { const { fileName, type, uri } = response.assets[0]; if (!uri) { throw new Error("No uri"); } const resp = await storage.upload({ uri, type, name: fileName, }); }});const jsonUri = await storage.upload(json);
function upload(data: any, options?: T): Promise<string>;
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.
// Upload an imagelaunchImageLibrary({ mediaType: "photo" }, async (response) => { if (response.assets?.[0]) { const { fileName, type, uri } = response.assets[0]; if (!uri) { throw new Error("No uri"); } const resp = await storage.upload({ uri, type, name: fileName, }); }}); // Upload an array of JSON objectsconst objects = [ { name: "JSON 1", text: "Hello World" }, { name: "JSON 2", trait: "Awesome" },];const jsonUris = await storage.uploadBatch(objects);
function uploadBatch( data: Array<any>, options?: T,): Promise<Array<string>>;