Failed to export a file using drive API
Problem
I am using: - googleapis@12.3.0 - node@4.3.2 I was trying to download a spreadsheet using Drive API v3 like this: [code block] Resulting file was corrupted. Same situation with 'application/pdf' - I could not open them. After some investigation, I noticed that node-request module downloads data as string (decoded as utf8) by default unless you specify encoding option set to `null`. (what I am downloading here are binary files!) [code block] By adding a line in drive.files.export() function like below, I was able to download the file successfully: [code block] I am aware this file is generated with swig, and probably other methods (like drive.files.get with "alt" set to "media" for binary data) are suffering from the same problem, I do not have sufficient knowledge to propose most effective solution to this. I hope some one could come up with a good idea to this problem.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Failed to export a file using drive API
Does this sample not work for you? https://developers.google.com/drive/v3/web/manage-downloads#downloading_google_documents
Trust Score
1 verification
- 1
Does this sample not work for you?
Does this sample not work for you?
- 2
https://developers.google.com/drive/v3/web/manage-downloads#downloading_google_d
https://developers.google.com/drive/v3/web/manage-downloads#downloading_google_documents
Validation
Resolved in googleapis/google-api-nodejs-client GitHub issue #618. Community reactions: 0 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep