flutter_aws_s3_client 0.4.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 88

Pub Package

flutter_aws_s3_client #

Supports downloading objects and listing objects in a bucket.

The heavy lifting was done by Amazon Cognito Identity SDK for Dart, this project contains just convenience methods for common use cases.

if you need more requests, you can use this instead to build what you need. If you implement more methods, feel free to open a pull request.

Usage #

Build the client #

    final AwsS3Client s3client = AwsS3Client(
       region: region,
       bucket: bucket,
       accessKey: accessKey,
       secretKey: secretKey,
       sessionToken: sessionToken //optional
     );

Get an object #

final response = await s3client.getObject("your/object/key"); 

List objects of the bucket #

ListBucketResult listBucketResult =
  await s3client.listObjects(prefix: "dir1/dir2/", delimiter: "/");
print(listBucketResult.toString());

If you want to use a custom http client, use the method buildSignedGetParams. This method returns an object containing the URL and the Authorization headers, which can be used to build the request with your preferred http client.

Download a large object to a file without keeping everything in-memory (streaming) #

Use the buildSignedGetParams method.

Example code (with ETag support):


Future download(String key, File file, [String etag = null]) async {

  final signedParams = awsS3Client.buildSignedGetParams(key: key);

  final request = await HttpClient().getUrl(signedParams.uri);

  for (final header in (signedParams.headers ?? const {}).entries) {
    request.headers.add(header.key, header.value);
  }
  if(eTag != null){
    request.headers.add(HttpHeaders.ifNoneMatchHeader, eTag);
  }
  final response = response = await request.close();
  if(response.statusCode != HttpStatus.ok){
     //handle error  
  }else{
     return response.pipe(file.openWrite());
  }
}

[0.4.1]

  • Update xml2json 4.0.0

[0.4.0]

  • Update dependency versions

[0.3.0]

  • BREAKING CHANGE: renamed 'path' parameter to 'key'
  • Fix bug that caused a wrong signature when key contains characters that need to be url-encoded

[0.2.0]

  • Check the status code before trying to parse responses. Throw exceptions on error status codes.

[0.1.0] - Remove dependency on flutter, Update dependencies

[0.0.4] - Add example

[0.0.3] - Fix homepage

[0.0.2] - Better documentation

[0.0.1] - Initial Release

  • Initial Release. Support GET Bucket (List Objects) and GET Object.

example/README.md

example #

A new Flutter project.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_aws_s3_client: ^0.4.1

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:flutter_aws_s3_client/flutter_aws_s3_client.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
76
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
88
Learn more about scoring.

We analyzed this package on Nov 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
amazon_cognito_identity_dart ^0.0.22 0.0.22
built_collection ^4.2.0 4.2.2 4.3.0
built_value ^7.0.0 7.0.0
http ^0.12.0+2 0.12.0+2
xml2json ^4.0.0 4.0.0
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.3
fixnum 0.10.11
http_parser 3.1.3
matcher 0.12.6
meta 1.1.8
path 1.6.4
pedantic 1.8.0+1
petitparser 2.4.0
quiver 2.1.2+1
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
xml 3.5.0
Dev dependencies
build_runner ^1.7.2
built_value_generator ^7.0.0
flutter_test
json_serializable ^3.2.2