We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modifying googleapis_examples/drive_upload_download_console, I'm attempting to convert already stored .docx, .xlsx, etc files to their corresponding Google Drive counterpart.
The following 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; }
results in the following error.
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.<anonymous closure> (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.<anonymous closure> (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)
Am I possibly creating the stream and consequently the media instance incorrectly?
The text was updated successfully, but these errors were encountered:
Solved. See SOF.
Sorry, something went wrong.
HOME
No branches or pull requests
Modifying googleapis_examples/drive_upload_download_console, I'm attempting to convert already stored .docx, .xlsx, etc files to their corresponding Google Drive counterpart.
The following code
results in the following error.
Am I possibly creating the stream and consequently the media instance incorrectly?
The text was updated successfully, but these errors were encountered: