Registry / storage / bunnycdn-storage

bunnycdn-storage

JSON →
library1.1.0jsnpmunverified

A lightweight TypeScript wrapper for the BunnyCDN Storage API, version 1.1.0. Supports file listing, upload (from buffer or file path), download (as buffer or stream), and deletion across multiple storage regions. The library provides a simple class-based interface with automatic endpoint resolution. It ships TypeScript definitions and has no external dependencies. Release cadence is low, with infrequent updates. Unlike the official SDK, this package is community-maintained and offers a more streamlined API.

npm install bunnycdn-storage
INSTALL
IMPORT
SIG · BUNNYCDN-STORAGE
B
bunnycdn-storage
storagejavascriptv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BunnyStorage
import BunnyStorage from 'bunnycdn-storage'
import { BunnyStorage } from 'bunnycdn-storage'
Default export only. Named export does not exist. In CommonJS, use require('bunnycdn-storage').default.
require('bunnycdn-storage').default
const BunnyStorage = require('bunnycdn-storage').default
const BunnyStorage = require('bunnycdn-storage')
CommonJS users must explicitly access .default due to ESM-CJS interop.
BunnyStorage constructor
new BunnyStorage('API-KEY', 'STORAGE-ZONE-NAME')
new BunnyStorage({ apiKey: '...', storageZone: '...' })
Constructor expects positional arguments: apiKey, storageZoneName, optional region.

Demonstrates creating a BunnyStorage client and performing list, upload, download, and delete operations.

import BunnyStorage from 'bunnycdn-storage'; import fs from 'fs'; const apiKey = process.env.BUNNY_API_KEY ?? ''; const storageZone = process.env.BUNNY_STORAGE_ZONE ?? ''; const storage = new BunnyStorage(apiKey, storageZone); async function main() { // List files const files = await storage.list(); console.log('Files:', files); // Upload from file path await storage.upload('/path/to/file.jpg'); // Upload from buffer const buffer = fs.readFileSync('/path/to/file.jpg'); await storage.upload(buffer, 'file.jpg'); // Download as buffer (default) const downloaded = await storage.download('file.jpg'); console.log('Downloaded size:', downloaded.length); // Download as stream const stream = await storage.download('file.jpg', 'stream'); // consume stream... // Delete file await storage.delete('file.jpg'); } main().catch(console.error);
Debug
Known issues
gotchaThe constructor requires region as third argument; if omitted defaults to Falkenstein (storage.bunnycdn.com). Passing an empty string may cause unexpected behavior.
fix
Always pass undefined or a valid region string (e.g., 'ny', 'la', 'sg'). Do not pass empty string.
affects: >=0.0.0
gotchaupload() with a file path argument must be a string path, not a URL or relative path without proper resolvability. Buffer upload requires second argument (filename).
fix
When uploading a file, use either a string path (absolute) or provide a buffer and filename.
affects: >=0.0.0
deprecatedThe download() method's second parameter 'arraybuffer' returns a Buffer; this naming is confusing and may be deprecated in a future version.
fix
Use 'buffer' or simply omit the second parameter to get a Buffer.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: BunnyStorage is not a constructor
Using named import instead of default import, or CommonJS without .default
fix
Use import BunnyStorage from 'bunnycdn-storage' (ESM) or const BunnyStorage = require('bunnycdn-storage').default (CJS)
Error: Cannot read properties of undefined (reading 'list')
Storage zone or API key invalid, or missing region causing request to fail
fix
Verify API key and storage zone name, and ensure correct region is set (e.g., 'ny' for New York)
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
41 hits · last 30 days
node
36
Resources
bunnycdn-storage — npm install bunnycdn-storage · libregistry