arnemolland / sigv4

Dart library for signing AWS requests with Signature Version 4
MIT License
17 stars 23 forks source link

[WEB] Cannot read property 'Symbol(dartx.toUpperCase)' of null #24

Open BartusZak opened 3 years ago

BartusZak commented 3 years ago
final _sigV4S3Client = Sigv4Client(
      keyId: "ACCESS_KEY",
      accessKey: "SECRET_KEY",
      region: config.region,
      serviceName: "s3",
    );

    final Dio _dioClient = Dio();
    _dioClient.interceptors.add(LogInterceptor());

    final String url =
        "https://bucket-name.s3-eu-west-1.amazonaws.com/kitten-small.png";

    FilePickerResult result = await FilePicker.platform.pickFiles();
    PlatformFile file = result.files.single;

    var response = await _dioClient.put(
      url,
      options: RequestOptions(headers: {"Content-Type": "image/" + "png"})
          .sign(_sigV4S3Client),
      data: file.bytes,
    );
[+6467 ms] TypeError: Cannot read property 'Symbol(dartx.toUpperCase)' of null
                        at client.Sigv4Client.new.signedHeaders (http://localhost:54836/packages/sigv4/src/client.dart.lib.js:108:22)
                        at Object.DioExtension$124sign [as DioExtension|sign] (http://localhost:54836/packages/sigv4/src/extensions/http.dart.lib.js:50:25)
                        at putFile (http://localhost:54836/packages/multibook/features/library/data/api/s3/S3Api.dart.lib.js:67:100)
                        at putFile.next (<anonymous>)
                        at http://localhost:54836/dart_sdk.js:39029:33
                        at _RootZone.runUnary (http://localhost:54836/dart_sdk.js:38886:58)
                        at _FutureListener.thenAwait.handleValue (http://localhost:54836/dart_sdk.js:33872:29)
                        at handleValueCallback (http://localhost:54836/dart_sdk.js:34432:49)
                        at Function._propagateToListeners (http://localhost:54836/dart_sdk.js:34470:17)
                        at _Future.new.[_completeWithValue] (http://localhost:54836/dart_sdk.js:34312:23)
                        at async._AsyncCallbackEntry.new.callback (http://localhost:54836/dart_sdk.js:34335:35)
                        at Object._microtaskLoop (http://localhost:54836/dart_sdk.js:39173:13)
                        at _startMicrotaskLoop (http://localhost:54836/dart_sdk.js:39179:13)
                        at http://localhost:54836/dart_sdk.js:34686:9
 sigv4: ^4.1.1
Flutter 1.26.0-17.3.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 4b50ca7f7f (2 weeks ago) • 2021-02-04 19:44:27 -0800      
Engine • revision 2c527d6c7e
Tools • Dart 2.12.0 (build 2.12.0-259.8.beta)
arnemolland commented 3 years ago

Hi! The library is not using dartx directly, so it might be an upstream issue related to web compatibility that might be fixed by upgrading dependencies. I'll try to reproduce and fix when I'm free.