Guest User

Untitled

a guest
Dec 11th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. // Download a file from Google Drive.
  2. Future downloadFile(drive.DriveApi api,
  3. Client client,
  4. String objectId,
  5. String filename) {
  6. return api.files.get(objectId).then((drive.File file) {
  7. // The Drive API allows one to download files via `File.downloadUrl`.
  8. return client.readBytes(file.downloadUrl).then((bytes) {
  9. var stream = new File(filename).openWrite()..add(bytes);
  10. return stream.close();
  11. });
  12. });
Add Comment
Please, Sign In to add comment