cloudflare_r2_uploader 1.0.0 copy "cloudflare_r2_uploader: ^1.0.0" to clipboard
cloudflare_r2_uploader: ^1.0.0 copied to clipboard

A Dart package for uploading files to Cloudflare R2 using AWS Signature Version 4. Supports progress tracking, automatic MIME detection, and returns the uploaded file URL.

πŸ“¦ Cloudflare R2 Uploader #

A simple Dart package to upload files directly to Cloudflare R2 using AWS Signature Version 4 signing. This package supports progress tracking, automatic MIME type detection, and returns the uploaded file URL on success.


✨ Features #

  • βœ… Upload files to Cloudflare R2 buckets
  • βœ… AWS S3–compatible request signing
  • βœ… Automatic MIME type detection
  • βœ… Upload progress callback
  • βœ… Pure Dart (no Flutter dependency)

πŸ“₯ Installation #

Add this to your pubspec.yaml:

dependencies:
  cloudflare_r2_uploader: ^1.0.0
<!-- 
This README describes the package. If you publish this package to pub.dev,
this README's contents appear on the landing page for your package.

For information about how to write a good package README, see the guide for
[writing package pages](https://dart.dev/tools/pub/writing-package-pages). 

For general information about developing packages, see the Dart guide for
[creating packages](https://dart.dev/guides/libraries/create-packages)
and the Flutter guide for
[developing packages and plugins](https://flutter.dev/to/develop-packages). 
-->

βš™οΈ Parameters

Parameter Type Description
accountId String Your Cloudflare account ID
accessKeyId String Cloudflare R2 Access Key ID
secretAccessKey String Cloudflare R2 Secret Access Key
bucketName String Name of the target bucket
region String (Optional) R2 region, defaults to auto
fileBytes Uint8List File content in bytes
fileName String Name to store the file as
folderName String? (Optional) Folder inside the bucket
onProgress Function(double) (Optional) Upload progress callback

πŸ› οΈ Example with Progress Indicator #

dart
await uploader.uploadFile( fileBytes: fileBytes, fileName: 'test.png', folderName: 'images', onProgress: (progress) { print('Progress: ${(progress * 100).toStringAsFixed(2)}%'); }, );

βœ… Requirements #

  • Cloudflare R2 account
  • R2 bucket created
  • Access Key & Secret Key generated from Cloudflare dashboard

πŸ§ͺ Testing #

You can write unit tests to mock HTTP requests and verify the AWS Signature v4 signing logic.


πŸ“Œ Notes #

  • Ensure your Cloudflare R2 bucket permissions allow PUT requests.
  • This package signs each request securely using AWS Signature Version 4.

πŸ“„ License #

MIT License. See the LICENSE file for details.


πŸ’‘ Contributions & Issues #

Pull requests are welcome!

For issues, please open a GitHub issue describing the problem.

3
likes
150
points
23
downloads

Publisher

verified publishersaiashirwad.com

Weekly Downloads

A Dart package for uploading files to Cloudflare R2 using AWS Signature Version 4. Supports progress tracking, automatic MIME detection, and returns the uploaded file URL.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

crypto, http, mime

More

Packages that depend on cloudflare_r2_uploader