@oprdev/cloudflare-r2-storage
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Cloudflare R2 storage

A simple way to manage files using Cloudflare R2 storage

Features

  • Upload files
  • List files
  • Delete files

Documentation

First, start installing the package in your project:

npm i @oprdev/cloudflare-r2-storage

Second, retrieve the variables to connect the package with Cloudflare storage.

[!IMPORTANT] To start using the package you will need from Cloudflare the following variables:

  • Cloudflare_access_key_ID
  • Cloudflare_access_key
  • Bucket name

Please check it out the Cloudflare Documentation

How it works

[!TIP] Key value is created from Project and Id

const bucket = new Bucket({
  endpoint,
  accessKeyId,
  secretAccessKey,
  bucketName,
});

// Upload file
await bucket.uploadFile({
  file,
  id: 'your-file-id',
  contentType: 'image/webp',
  project: 'your-project-name',
});

// Get file by project
await bucket.getKeysByEntity({
  entity: 'your-project-name',
});

// Delete file
await bucket.deleteItemByKey({
  key: 'your-project-name/your-file-id',
});

/@oprdev/cloudflare-r2-storage/

    Package Sidebar

    Install

    npm i @oprdev/cloudflare-r2-storage

    Weekly Downloads

    1

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    15 kB

    Total Files

    12

    Last publish

    Collaborators

    • oprdev