aws_interop 2.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 11

s3_dart

Dart wrapper for Amazon AWS.

Some additional type information has been added to the .d.ts file on an as-needed basis.

Usage

see the example/ directory

Generating the library

dart_js_facade_gen lib/aws-sdk.d.ts > lib/aws_sdk.dart

Note: The committed version of this library differs from the dart_js_facade_gen output. This is necessary until https://github.com/dart-lang/js_facade_gen/issues/20 is resolved.

The .min.js file

the .min.js file has been created by running UglifyJS due to Uint8List bugs with the packaged .min.js file.

Known Issues

Loading objects from the S3 API with newer versions, or the minified version of 2.4.13 of the JS library will not return a Uint8List in non-Dartium browsers.

Features and bugs

Please file feature requests and bugs at the issue tracker.

Changelog

1.0.0

  • Initial version

example/main.dart

@JS()
library apptreeTest;

import 'package:aws_interop/aws_sdk.dart' as aws;
import 'dart:async';
import 'dart:html';
import 'package:js/js.dart';
import 'package:jsifier/jsifier.dart';
import 'dart:convert';

Future main() async {
  var accessKey = '';
  var secretKey = '';
  var region = '';
  var bucketName = '';

  aws.config.credentials = new aws.Credentials(accessKey, secretKey);
  aws.config.region = region;

  var params = {'Bucket': bucketName, 'Key': ''};
  var options = {'params': params};
  var bucket = new aws.S3(options);
  var uploadFileBtn = querySelector('#uploadFileBtn');

  uploadFileBtn.onClick.listen((evt) async {
    var key = (querySelector('#fileName') as InputElement).value;
    var request = new aws.PutObjectRequest();
    request.Body = await getFileBody();
    request.Key = key;
    request.Bucket = bucketName;
    bucket.putObject(request, allowInterop((err, data) {
      print('error: $err');
      print('data: $data');
    }));
  });

  var getFileButton = querySelector('#getFileBtn');
  getFileButton.onClick.listen((evt) {
    var request = new aws.GetObjectRequest();
    var key = (querySelector('#fileName') as InputElement).value;
    request.Key = key;
    request.Bucket = bucketName;
    bucket.getObject(request, allowInterop((err, data) {
      var obj = Jsifier.decode(data);
      print('content-type: ${obj["ContentType"]}');
      print('data length: ${obj["Body"]["length"]}');
    }));
  });

  var deleteFileButton = querySelector('#deleteFileBtn');
  deleteFileButton.onClick.listen((evt) {
    var key = (querySelector('#fileName') as InputElement).value;
    var request = new aws.DeleteObjectRequest();
    request.Key = key;
    request.Bucket = bucketName;
    bucket.deleteObject(request, allowInterop((err, data) {
      if (err != null) {
        print('error deleting file: $err');
        return;
      }
      print('deleted file $key');
    }));
  });
}

Future<List<int>> getFileBody() async {
  var uploadInput = querySelector('#fileUpload');
  final files = uploadInput.files;
  if (files.length == 1) {
    final file = files[0];
    final reader = new FileReader();
    var onDone = reader.onLoadEnd.first;
    reader.readAsDataUrl(file);
    await onDone;
    var upload = reader.result.toString().split(',').elementAt(1);
    return BASE64.decode(upload);
  }
  return null;
}

Use this package as a library

1. Depend on it

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


dependencies:
  aws_interop: ^2.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support 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_interop/aws_sdk.dart';
  
Version Uploaded Documentation Archive
2.0.1 Nov 3, 2016 Go to the documentation of aws_interop 2.0.1 Download aws_interop 2.0.1 archive
2.0.0 Oct 19, 2016 Go to the documentation of aws_interop 2.0.0 Download aws_interop 2.0.0 archive
1.2.0 Sep 1, 2016 Go to the documentation of aws_interop 1.2.0 Download aws_interop 1.2.0 archive
1.1.0 Aug 29, 2016 Go to the documentation of aws_interop 1.1.0 Download aws_interop 1.1.0 archive
1.0.1 Aug 9, 2016 Go to the documentation of aws_interop 1.0.1 Download aws_interop 1.0.1 archive
1.0.0 Aug 9, 2016 Go to the documentation of aws_interop 1.0.0 Download aws_interop 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
23
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
11
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <2.0.0