Skip to content

Commit

Permalink
Fixed the download from Google Drive
Browse files Browse the repository at this point in the history
Based on this example of performing a file download with Google Drive
API client libraries:
https://developers.google.com/drive/v3/web/manage-downloads

Closes #59
  • Loading branch information
abbyad authored and alxndrsn committed Feb 28, 2018
1 parent 112275d commit dd3ecbd
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/fn/fetch-forms-from-google-drive.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,13 @@ module.exports = projectDir => {

info(`Exporting ${remoteName} from google drive to ${target}…`);

drive.files.export(fetchOpts, (err, buffer) => {
if(err) return reject(err);
try {
fs.writeBinary(target, buffer);
info(`Successfully wrote ${target}.`);
resolve();
} catch(e) {
reject(e);
}
});
drive.files.export(fetchOpts)
.on('end', () => {
info(`Successfully wrote ${target}.`);
resolve();
})
.on('error', err => reject(err))
.pipe(fs.fs.createWriteStream(target));
}));
}
});
Expand Down

0 comments on commit dd3ecbd

Please sign in to comment.