Download S3 or R2 Objects as a ZIP
Authorize Amazon S3 or Cloudflare R2 objects, then package signed URLs as one ZIP without exposing storage credentials.
The browser should receive short-lived object URLs, never S3, R2, or S3-compatible storage credentials.
Prepare a signed source list
Your backend endpoint should:
- authenticate the application user;
- authorize each requested object;
- create a short-lived signed URL; and
- return only
{ url, filename }entries.
The exact signing code depends on the storage provider and belongs on the server.
Fetch the list and create the ZIP
import { createZip } from '@eazip/core';
type SignedSource = {
url: string;
filename: string;
};
const response = await fetch('/api/exports/123/files', {
credentials: 'include',
});
if (!response.ok) {
throw new Error('Could not prepare export files');
}
const files = (await response.json()) as SignedSource[];
const result = await createZip({
files,
zipName: 'project-files.zip',
});
result.downloadAll();For a Local job, the bucket or CDN must allow browser CORS and each signed URL must remain valid until its file has been fetched.
Use Cloud for larger object sets
Cloud fetches the same signed URLs outside the browser:
const result = await createZip({
strategy: 'cloud',
publicKey: 'pk_ez_...',
files,
zipName: 'project-files.zip',
});Add the bucket or CDN hostname to the Public App's allowed source hosts. Make the signed URL lifetime long enough for Eazip Cloud to start and finish reading the source.
Keep the URL list on the server when needed
If even the signed URL list is sensitive, create the Cloud session on your backend and return only its session handle.
Continue with Backend-created sessions or Public keys and origins.
Download Selected Files as a ZIP in React
Turn selected gallery, asset picker, or document items into one browser-generated ZIP with React and EazipTray.
Show ZIP Progress and Let Users Cancel or Retry
Show ZIP progress in React, let users cancel active work, and retry failed downloads with EazipTray or useEazip.