Skip to content

Download Files

Download files from Zapdos storage to your local filesystem.

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 path
const 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 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 signed download URLs for use in your application:

// Get multiple URLs
const 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 URL
const singleResult = await client.getDownloadUrl("object-id-123");
if (singleResult.data) {
console.log("URL:", singleResult.data.url);
console.log("Expires at:", singleResult.data.expires_at);
}

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.