cloudflare_r2 0.0.5
cloudflare_r2: ^0.0.5 copied to clipboard
Flutter plugin for Cloudflare R2.
cloudflare_r2 #
Flutter CloudFlare R2 plugin project. It's using a aws_signature_v4 to access CloudFlare R2
For now only get/put/delete Object on R2 Bucket
Tested on
#
Platform | get | put | delete |
---|---|---|---|
Windows | 👍 | 👍 | 👍 |
Android | 👍 | 👍 | 👍 |
Linux | need test | need test | need test |
MacOS | need test | need test | need test |
Ios | need test | need test | need test |
Getting Started #
Check the Example
//call CloudFlareR2.init before using any call
CloudFlareR2.init(
accoundId: 'your accound ID',
accessKeyId: 'your access id',
secretAccessKey: 'your secret acess key',
);
//to get the Object
await CloudFlareR2.getObject(
bucket: 'bucket name',
objectName: 'name of the object',
pathToSave: 'path to save the file',
onReceiveProgress: (total, received) {
//do the progress of the download here
},
);
//upload some object
await CloudFlareR2.putObject(
bucket: 'bucket name',
objectName: 'name of the object',
objectBytes: objectBytes,
contentType: 'content type of the file here');
//Delete some object
await CloudFlareR2.deleteObject(
bucket: 'bucket name',
objectName: 'name of the object');
Migration from 0.0.3 to 0.04 #
Before init #
await CloudFlareR2.init();
Now init #
CloudFlareR2.init(
accoundId: 'your accound ID',
accessKeyId: 'your access id',
secretAccessKey: 'your secret acess key',
);
Before getObject #
//to get the Object
Uint8List object = await CloudFlareR2.getObject(
accountId: controllerAccountId.text,
accessId: controllerAcessId.text,
secretAccessKey: controllerSecretAccessKey.text,
bucket: controllerBucket.text,
objectName: controllerObjectName.text,
);
Now getObject #
await CloudFlareR2.getObject(
bucket: controllerBucket.text,
objectName: controllerObjectName.text,
pathToSave: 'path to save the file',
onReceiveProgress: (total, received) {
//do the progress of the download here
},
);
Before putObject #
//upload some object
await CloudFlareR2.putObject(
bucket: controllerBucket.text,
accountId: controllerAccountId.text,
accessId: controllerAcessId.text,
secretAccessKey: controllerSecretAccessKetext,
objectName: controllerObjectName.text,
objectBytes: objectBytes,
cacheControl: controllercacheControl.text,
contentType: controllercontentType.text);
Now putObject #
await CloudFlareR2.putObject(
bucket: controllerBucket.text,
objectName: controllerObjectName.text,
objectBytes: objectBytes,
contentType: 'content type of the file here');
Before deleteObject #
//Delete some object
await CloudFlareR2.deleteObject(
bucket: controllerBucket.text,
accountId: controllerAccountId.text,
accessId: controllerAcessId.text,
secretAccessKey: controllerSecretAccessKey.text,
objectName: controllerObjectName.text);
Now deleteObject #
//Delete some object
await CloudFlareR2.deleteObject(
bucket: controllerBucket.text,
objectName: controllerObjectName.text);