UNPKG

bunnycdn-storage-ts

Version:

![GitHub](https://img.shields.io/github/license/bynarig/bunnycdn-storage-ts?style=flat-square) [![npm](https://img.shields.io/npm/v/bunnycdn-storage-ts?style=flat-square)](https://www.npmjs.com/package/bunnycdn-storage-ts)

37 lines (27 loc) 1.42 kB
# bunnycdn-storage ![GitHub](https://img.shields.io/github/license/bynarig/bunnycdn-storage-ts?style=flat-square) [![npm](https://img.shields.io/npm/v/bunnycdn-storage-ts?style=flat-square)](https://www.npmjs.com/package/bunnycdn-storage-ts) a small wrapper for the [bunnycdn](https://bunnycdn.com) storage api # Building install dependencies with npm/pnpm and then run `npm build` or `pnpm build` # Usage ```ts import BunnyStorage from 'bunnycdn-storage-ts'; // No region specified, defaults to Falkenstein (storage.bunnycdn.com) const bunnyStorage = new BunnyStorage('API-KEY', 'STORAGE-ZONE-NAME'); // Specific region (ny.storage.bunnycdn.com) const bunnyStorageRegion = new BunnyStorage('API-KEY', 'STORAGE-ZONE-NAME', 'ny'); // list all files in zone / path const files = await bunnyStorage.list(); const filesInDir = await bunnyStorage.list('/images'); // upload a file from buffer or filename bunnyStorage.upload('/tmp/bunny.jpg'); bunnyStorage.upload(fs.readFileSync('/tmp/bunny.jpg'), 'bunny.jpg') // download a file from the servers bunnyStorage.download('bunny.jpg'); // Buffer (default) bunnyStorage.download('bunny.jpg', 'arraybuffer'); // Buffer bunnyStorage.download('bunny.jpg', 'stream'); // ReadableStream // delete a file bunnyStorage.delete('bunny.jpg'); ``` # Disclaimer Note that this project and the maintainer(s) of this repository are in no way, shape or form affiliated with BunnyCDN.