aws_s3_client 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 86

AWS_S3_client #

Client library to interact with the AWS S3 API (and other compatible S3 services, such as Yandex Cloud Storage)

Usage #

A simple usage example:

import 'package:aws_s3_client/aws_s3.dart';

main() async {
  Spaces spaces = Spaces(
    region: "region",
    accessKey: "accessKey",
    secretKey: "secretKey",
  );
  for (String name in await spaces.listAllBuckets()) {
    print('bucket: ${name}');
    if (name == 'yourBucket') {
      Bucket bucket = spaces.bucket(name);
      await for (BucketContent content
          in bucket.listContents(prefix: 'test')) {
        print('key: ${content.key}; size: ${content.size}');
      }
    }
  }
  Bucket bucket = spaces.bucket('yourBucket');

  String etag = await bucket.uploadFile(
      'test/test.md', 'README.md', 'text/plain', Permissions.public);
  print('upload: $etag');

  print('done');
}

For more usage examples please see tests

References #

Thanks https://github.com/nbspou for inspiration of creating this package

0.1.0 #

  • Initial version

example/example.dart

import 'dart:io';
import 'package:aws_s3_client/aws_s3_client.dart';

main() async {
  Spaces spaces = Spaces(
    region: "region",
    accessKey: "accessKey",
    secretKey: "secretKey",
  );
  for (String name in await spaces.listAllBuckets()) {
    print('bucket: ${name}');
    if (name == 'yourBucket') {
      Bucket bucket = spaces.bucket(name);
      await for (BucketContent content in bucket.listContent(prefix: 'test')) {
        print('key: ${content.key}; size: ${content.size}');
      }
    }
  }
  Bucket bucket = spaces.bucket('yourBucket');

  File file = File('README.md');

  String etag = await bucket.uploadFile(
      'test/test.md', file.readAsBytesSync(), 'text/plain', Permissions.public);
  print('upload: $etag');

  print('done');
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  aws_s3_client: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:aws_s3_client/aws_s3_client.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
78
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
86
Learn more about scoring.

We analyzed this package on Jun 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.9+1

Analysis suggestions

Package not compatible with runtime flutter-web of web

Because of the import of dart:io via the import chain package:aws_s3_client/aws_s3_client.dart->package:aws_s3_client/src/bucket.dart->package:aws_s3_client/src/stream_transformers.dart->package:aws_s3_client/src/client.dart->package:http_client/console.dart->dart:io

Package not compatible with runtime web

Because of the import of dart:io via the import chain package:aws_s3_client/aws_s3_client.dart->package:aws_s3_client/src/bucket.dart->package:aws_s3_client/src/stream_transformers.dart->package:aws_s3_client/src/client.dart->package:http_client/console.dart->dart:io

Health suggestions

Fix lib/src/bucket.dart. (-1 points)

Analysis of lib/src/bucket.dart reported 2 hints:

line 180 col 9: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

line 184 col 9: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (xml).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
crypto ^2.0.6 2.1.5
http ^0.12.0+2 0.12.1
http_client ^1.0.3 1.4.0
meta ^1.1.7 1.1.8
mime ^0.9.6 0.9.6+3
path ^1.6.4 1.7.0
xml ^3.5.0 3.7.0 4.2.0
Transitive dependencies
buffer 1.0.6
charcode 1.1.3
collection 1.14.12
convert 2.1.1
executor 2.2.1
http_parser 3.1.4
pedantic 1.9.0
petitparser 3.0.4
source_span 1.7.0
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
test ^1.0.0