Download Files
Download files from Zapdos storage to your local filesystem.
Download Single File
Section titled “Download Single File”Download a file by its object ID:
import { createClient } from "zapdos-js";
const client = createClient({ apiKey: process.env.ZAPDOS_API_KEY,});
// Download to specific file pathconst result = await client.download("object-id-123", "./downloaded-video.mp4");if (result.data) { console.log("Downloaded to:", result.data.file);}
// Download to directory (filename = object ID)const result = await client.download("object-id-123", "./downloads/");
Download Multiple Files
Section titled “Download Multiple Files”Download several files to a directory:
const result = await client.downloadBatch( ["object-id-123", "object-id-456", "object-id-789"], "./downloads/");
if (result.data) { console.log("Downloaded files:", result.data.files); // ["./downloads/object-id-123", "./downloads/object-id-456", ...]}
Get Download URLs
Section titled “Get Download URLs”Get signed download URLs for use in your application:
// Get multiple URLsconst result = await client.getDownloadUrls(["object-id-123", "object-id-456"]);
if (result.data) { console.log("URLs:", result.data.urls); console.log("Expires at:", result.data.expires_at);}
// Get single URLconst singleResult = await client.getDownloadUrl("object-id-123");if (singleResult.data) { console.log("URL:", singleResult.data.url); console.log("Expires at:", singleResult.data.expires_at);}
Error Handling
Section titled “Error Handling”Downloads return result objects with error handling:
const result = await client.download("object-id-123", "./video.mp4");
if (result.error) { console.error("Download failed:", result.error.message);} else { console.log("Downloaded successfully:", result.data.file);}
Downloaded files retain their original format and can be used immediately.