Search code examples
flutterdartdio

Upload s3 presignedurl using dio and multi_image_picker package in Flutter


I using
dio, multi image picker package

Here is my implement sudo code

Asset asset = result //pick result;
ByteData byteData = await asset.getByteData();
var buffer = byteData.buffer;
postData = buffer.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes);

//and

 Response response = await nDio.put(
        url,
        data: Stream.fromIterable(postData.map((e) => [e])), //create a Stream<List<int>>
        options: Options(
          headers: {
            Headers.contentLengthHeader: postData.length, // set content-length
          },
        ),
      );

It was well work, but suddenly something wrong.
(just upgrade flutter framework) I tried test in Postman then wrok fine. So not wrong url...

I think it seems that encoding error. but I don't know how to do If I uploaded. my file is show like this
enter image description here


Solution

  • It fixed just add content-type