How to create a blob with dart:io

634 views
Skip to first unread message

Thomas Delalonde

unread,
Aug 19, 2013, 8:07:52 AM8/19/13
to
Hi, i created a simple server with dart:io.

It download an image from flick with the http package like :
     http.get(url, headers: {
        "Content-Type": "application/octet-binary"
      }).then((value) {
        _images[url.split("/").last] = value.body;
        i++;

        if (i >= 30)
        {
          if(!_completer.isCompleted) _completer.complete();
        }
        else loop();

      });

then a wep app call my server to download an image.
but how server it like a blob ?

on my web app, i specify request.responseType = "blob";
but don't know what to do on the server to send a blob.

any ideas ?

Regards,

Thomas.

Thomas Delalonde

unread,
Aug 19, 2013, 9:52:29 AM8/19/13
to mi...@dartlang.org
Even if i store value.bodyBytes from http.get, then send it to the client
the blob receive and use to create a ImageElement (blob transform to base64 with FileReader) give me an error

so what to do to send a correct blob format, am i missing a step ? 

Thomas Delalonde

unread,
Aug 19, 2013, 11:47:08 AM8/19/13
to mi...@dartlang.org
Ok found the issue

in fact i use HttpClientResponse.write to send my byteBuffer, which convert it to int (like it seems so)
i need to do .add(myBuffer) to send correctly my byte buffer

Regards,

Thomas.

Bob Nystrom

unread,
Aug 19, 2013, 1:24:00 PM8/19/13
to General Dart Discussion
Thanks for following up on this for anyone else who runs into this issue!

Cheers!

- bob
Reply all
Reply to author
Forward
0 new messages