0 purchases
amarcdn s4
AmarCDN SDK for Flutter #
AmarCDN is a product of TongBari. We have started our domain and hosting business since 2011. Over this time, we have re-branding ourself. Now we are providing Global Standard compatible cloud services.
What is S4? #
Before going to tell about S4 we have to know about S3. S3 is the abbreviation of Simple Storage Service. So the S4 is Secured S3. Finally S4 stands for Secured - Simple Storage Service.
What is Bucket? #
A container for objects stored in AmarCDN S4. AmarCDN will provide a subdomain for the bucket. The bucket is globally unique but your subdomain will be prefix with regional url. Bucket name should be 4-60 chararacters
Install via flutter packages. #
flutter pub add amarcdn_s4
copied to clipboard
Create instance of AmarCDN with below code. #
AmarCDN _amarCDN = AmarCDN(apiKey: _apiKey,
apiSecretKey: _apiSecretKey, regionTitle: _regionTitle);
copied to clipboard
Create Bucket Example #
Future createBucket() async {
try {
final response = await _amarCDN.createBucket(
bucketName: 'nizam', isPrivate: false);
debugPrint(response.data.toString());
} catch (e) {
debugPrint(e.toString());
}
copied to clipboard
Get Bucket List Example #
Future getBucketList() async {
try {
final response = await _amarCND.getBucketList();
debugPrint(response.data.toString());
} catch (e) {
debugPrint(e.toString());
}
}
copied to clipboard
Delete Bucket Example #
Future deleteBucket() async {
try {
final response = await _amarCND.deleteBucket(
bucketName: 'shamrat',
bucketId: 'a2dfddd5-f3e2-46b9-9dff-d4fe1e30c344',
);
debugPrint(response.data.toString());
} catch (e) {
debugPrint(e.toString());
}
}
copied to clipboard
Single File Upload Example #
Future uploadSingleFile() async {
FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result != null) {
File file = File(result.files.single.path!);
try {
_amarCND
.uploadSingleFile(
bucketName: 'testfolder',
bucketId: 'a2dfddd5-f3e2-46b9-9dff-d4fe1e30c344',
file: file,
)
.listen((response) => debugPrint(response.data.toString()));
} catch (e) {
debugPrint(e.toString());
}
} else {
debugPrint('could not pick files');
}
}
copied to clipboard
Multiple File Upload Example #
Future<void> multipleFileUpload() async {
FilePickerResult? result =
await FilePicker.platform.pickFiles(allowMultiple: true);
if (result != null) {
List<File> files = result.paths.map((path) => File(path!)).toList();
try {
_amarCND
.uploadMultipleFile(
bucketName: 'testfolder',
bucketId: 'a2dfddd5-f3e2-46b9-9dff-d4fe1e30c344',
files: files,
)
.listen((streamResponse) => streamResponse
.listen((response) => debugPrint(response.data.toString())));
} catch (e) {
debugPrint(e.toString());
}
} else {
debugPrint('could not pick files');
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.