O'Reilly logo

Dart: Scalable Application Development by Ivo Balbaert, Sergey Akopkokhyants, Davy Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with blobs

In the previous recipe, in step 1, we used a client HttpRequest object and its method getString. In this recipe, we want to download a blob (binarylargeobject) file, for example, a large image, audio, or video file. But first, you need to prepare for this if you need to do more than just download a string from a URL resource to process it on the client. You need to go through the following steps (for the code, see request_prep.dart in the project request_blob).

Getting ready

  1. Create an HttpRequest object as shown in the following code:
    import 'dart:html';
    
    void main() {
    var path = 'http://learningdart.org';
    var request = new HttpRequest();
    
  2. Open it (here, with the HTTP GET method) as shown in the following code:
    request ..open('GET', ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required