cloudflare_r2_uploader 1.0.0
SDKdartflutter
Platformandroidioswindowslinuxmacosweb
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
✅ 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.