title: Uncaught Error: Class 'int' has no instance getter 'length'
body: <p><strong>Am I possibly creating the stream and consequently the media instance incorrectly?</strong></p>
  
  <p>Modifying <a href="https://github.com/dart-lang/googleapis_examples/blob/master/drive_upload_download_console/bin/main.dart" rel="nofollow">googleapis_examples/drive_upload_download_console</a>, I'm attempting to convert already stored .docx, .xlsx, etc files to their corresponding Google Drive counterpart.</p>
  
  <p>The following code</p>
  
  <pre><code>import 'dart:async';
  import 'dart:io';
  
  import 'package:http/http.dart' show Client;
  import 'package:googleapis/common/common.dart' show Media, DownloadOptions;
  import 'package:googleapis/drive/v2.dart' as drive;
  import 'package:path/path.dart' as path;
  
  Future convertFile(drive.DriveApi api, 
                      Client client, 
                      String objectId) {
    var completer = new Completer();
    api.files.get(objectId).then((drive.File file) {
      var fileName = path.basenameWithoutExtension(file.title);
      var parents = file.parents;
  
      client.readBytes(file.downloadUrl).then((bytes) {
        var driveFile = new drive.File()
        ..title = fileName
        ..mimeType = 'application/vnd.google-apps.document'
        ..parents = parents;
        api.files.insert(driveFile)
        .then((driveFile){
          var byteList = bytes.toList();
          var stream = new Stream.fromIterable(byteList);
          var media = new Media(stream, byteList.length);
          api.files.update(new drive.File(), driveFile.id, uploadMedia: media)
          .then((drive.File f){
            stream.close().whenComplete((){
              api.files.delete(objectId)
              .then((_){
                completer.complete(true);
                print("Converted ${f.id}");
              });
            });
          });
        });
      });
    });
    return completer.future;
  }
  </code></pre>
  
  <p>results in the following error.</p>
  
  <pre><code>Unhandled exception:
  Uncaught Error: Class 'int' has no instance getter 'length'.
  
  NoSuchMethodError: method not found: 'length'
  Receiver: 80
  Arguments: []
  Stack Trace:
  #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
  #1      Base64Encoder.bind.onData (package:googleapis/src/common_internal.dart:325:42)
  #2      _RootZone.runUnaryGuarded (dart:async/zone.dart:1093)
  #3      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341)
  #4      _IterablePendingEvents.handleNext (dart:async/stream_impl.dart:549)
  #5      _PendingEvents.schedule.&lt;anonymous closure&gt; (dart:async/stream_impl.dart:671)
  #6      _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
  #7      _asyncRunCallback (dart:async/schedule_microtask.dart:48)
  #8      _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:84)
  #9      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:131)
  
  #0      _rootHandleUncaughtError.&lt;anonymous closure&gt; (dart:async/zone.dart:886)
  #1      _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
  #2      _asyncRunCallback (dart:async/schedule_microtask.dart:48)
  #3      _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:84)
  #4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:131)
  </code></pre>