Microservice to zip files on Cloudflare Worker - A serverless solution for creating ZIP archives from base64-encoded files directly on the edge.
This lightweight microservice leverages Cloudflare Workers to create ZIP archives on the fly. Perfect for scenarios where you need to bundle multiple files into a ZIP archive without server infrastructure. The service accepts base64-encoded files via a simple REST API endpoint and returns a ready-to-download ZIP file.
- 📦 Create ZIP archives from multiple files
- 🚀 Fast and efficient processing using Cloudflare Workers
- 💾 Handles base64-encoded file data
- 📅 Automatically generates timestamped ZIP filenames
- 🔒 Built with TypeScript for type safety
- ⚡ Powered by Hono framework
- 🗜️ Uses littlezipper for ZIP creation
- Maximum of 10 images simultaneously
- Each file up to 200KB in size
- Larger files or higher volumes need additional testing
- Clone the repository:
git clone https://github.com/Puliczek/cloudflare-to-zip.git
cd cloudflare-to-zip
- Install dependencies:
npm install
To run the project locally:
npm run dev
This will start the development server using Wrangler.
Deploy to Cloudflare Workers:
npm run deploy
Creates a ZIP archive from the provided files.
[
{
"name": "test1.txt",
"base64": "data:text/plain;base64,SGVsbG8gV29ybGQh"
},
{
"name": "test2.txt",
"base64": "data:text/plain;base64,VGhpcyBpcyBhIHRlc3QgZmlsZQ=="
}
]
- Success: Returns a ZIP file with
application/zip
content type - Error: Returns JSON with error details
- 400: No files provided
- 500: Processing error
const response = await fetch('https://your-worker.workers.dev/zip', {
method: 'POST',
body: JSON.stringify([
{
name: 'example.txt',
base64: 'data:text/plain;base64,SGVsbG8gV29ybGQh'
}
])
});
if (response.ok) {
const blob = await response.blob();
// Handle the ZIP file
}
- Cloudflare Workers
- Hono - Fast, Lightweight, Web-standards Web Framework
- TypeScript
- littlezipper
MIT License
Contributions are welcome! Please feel free to submit a Pull Request.