Upload and download files from decentralized storage systems.
// Create a default storage class with a client ID when used in client-side applicationsconst storage = new ThirdwebStorage({ clientId: "your-client-id" }); // Create a default storage class with a secret key when used in server-side applicationsconst storage = new ThirdwebStorage({ secretKey: "your-secret-key" }); You can get a clientId and secretKey from https://thirdweb.com/create-api-key // Upload any file or JSON objectconst uri = await storage.upload(data);const result = await storage.download(uri); // Or configure a custom uploader, downloader, and gateway URLsconst gatewayUrls = { // We define a mapping of schemes to gateway URLs "ipfs://": [ "https://ipfs.thirdwebcdn.com/ipfs/", "https://cloudflare-ipfs.com/ipfs/", "https://ipfs.io/ipfs/", ],};const downloader = new StorageDownloader();const uploader = new IpfsUploader();const clientId = "your-client-id";const storage = new ThirdwebStorage({ clientId, uploader, downloader, gatewayUrls });