better_aliyun_oss 0.0.8 copy "better_aliyun_oss: ^0.0.8" to clipboard
better_aliyun_oss: ^0.0.8 copied to clipboard

A Simple Aliyun OSS Upload for Flutter.

better_aliyun_oss #

A Simple Aliyun OSS Upload for Flutter.

Install Started #

  1. Add this to your pubspec.yaml file:
dependencies:
  better_aliyun_oss: ^0.0.8
  1. Install it
$ flutter packages get

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!);
    }
  }

Feature #

  • simple upload file to Aliyun OSS.
  • multipart upload file to Aliyun OSS.
1
likes
100
pub points
59%
popularity

Publisher

unverified uploader

A Simple Aliyun OSS Upload for Flutter.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-2-Clause (license)

Dependencies

better_file_md5_plugin, convert, crypto, dio, flutter, http_parser, intl, path, tuple, xml

More

Packages that depend on better_aliyun_oss