flutter_oss_aliyun 1.0.3 icon indicating copy to clipboard operation
flutter_oss_aliyun: ^1.0.3 copied to clipboard

oss aliyun plugin for flutter and upport STS to access OSS temporarily

flutter_oss_aliyun #

Oss aliyun plugin for flutter. Use sts policy to authenticate the user.

flutter pub: https://pub.dev/packages/flutter_oss_aliyun

oss sts document: https://help.aliyun.com/document_detail/100624.html

Feature has Supported #

  • [x] upload object
  • [x] get object
  • [x] save object in files
  • [x] delete object

Feature ready to Support #

  • [ ] List buckets
  • [ ] callback when upload object
  • [ ] upload multiple objects at once
  • [ ] delete multiple objects at once

Usage #

First, add flutter_oss_aliyun as a dependency in your pubspec.yaml file.

dependencies:
  flutter_oss_aliyun: ^1.0.3

Don't forget to flutter pub get.

1. init the client, we provide two ways to do it. #

use sts server, just provide the sts url from our backend server:

Client.init(
    stsUrl: "server url get sts token",
    ossEndpoint: "oss-cn-beijing.aliyuncs.com",
    bucketName: "bucket name",
);

This sts url api at least return the data:

{
  "AccessKeyId": "AccessKeyId",
  "AccessKeySecret": "AccessKeySecret",
  "SecurityToken": "SecurityToken",
  "Expiration": "2022-03-22T11:33:06Z"
}

you can also customize the way to get sts json response.

Client.init(
    ossEndpoint: "oss-cn-beijing.aliyuncs.com",
    bucketName: "bucketName",
    tokenGetter: _tokenGetterMethod
);

String _tokenGetterMethod() {
  return '''{
        "AccessKeyId": "access id",
        "AccessKeySecret": "AccessKeySecret",
        "SecurityToken": "security token",
        "Expiration": "2022-03-22T11:33:06Z"
    }''';
}

2. put the object to oss #

final bytes = "file bytes".codeUnits;
await Client().putObject(bytes, "test.txt");

3. get the object from oss #

await Client().getObject("test.txt");

4. download the object from oss #

await Client().downloadObject("test.txt", "./example/test.txt");

5. delete the object from oss #

await Client().deleteObject("test.txt");
4
likes
130
pub points
54%
popularity

Publisher

unverified uploader

oss aliyun plugin for flutter and upport STS to access OSS temporarily

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

crypto, dio, flutter, mime_type

More

Packages that depend on flutter_oss_aliyun