better_aliyun_oss

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

better aliyun oss

better_aliyun_oss #
A Simple Aliyun OSS Upload for Flutter.
Install Started #

Add this to your pubspec.yaml file:

dependencies:
better_aliyun_oss: ^0.0.8
copied to clipboard

Install it

$ flutter packages get
copied to clipboard
Normal usage #
late BetterAliyunOssClient ossClient;

late StreamSubscription eventStreamSubscription;

@override
void initState() {
super.initState();

ossClient = BetterAliyunOssClient(credentials);
eventStreamSubscription = ossClient.eventStream.listen((event) {
print("$event");
});
}

Future<BetterAliyunOssCredentials?> credentials() async {
final credentials = {
"SecurityToken": "",
"AccessKeyId": "",
"AccessKeySecret": "",
"Expiration": "",
};
return BetterAliyunOssCredentials.fromMap(credentials);
}

void uploading() async {
final objectFileName = Uuid().v1().replaceAll("-", "") + path.extension(file.path);
final objectPath = "image/${DateFormat("yyyyMM").format(DateTime.now())}/$objectFileName";

simplePutRequest = ossClient.putObject(
bucket: () async => "my-bucket",
endpoint: () async => "oss-cn-hangzhou.aliyuncs.com",
domain: () async => "https://domain.com",
objectPath: objectPath,
contentType: lookupMimeType(file.path) ?? "application/octet-stream",
path: file.path,
);

print("简单数据上传请求 id : ${simplePutRequest.requestTaskId}");
}

void cancelSimpleUpload() {
if (simplePutRequest != null) {
ossClient.cancelPutObject(simplePutRequest!);
}
}
copied to clipboard
Feature #

✅ simple upload file to Aliyun OSS.
✅ multipart upload file to Aliyun OSS.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.