Skip to content
New issue

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

Not able to download file (using google drive v3 api) #598

Closed
HimanshuLakra opened this issue Jul 8, 2017 · 5 comments
Closed

Not able to download file (using google drive v3 api) #598

HimanshuLakra opened this issue Jul 8, 2017 · 5 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@HimanshuLakra
Copy link

I want to download .xls file from google drive.
drive_service.list_files is working fine for me to get file_id but for download following code
drive_service.export_file(file_id,'application/vnd.ms-excel',
download_dest: "/home/tt/Desktop/Automation/TestSheet.xls")

is giving error

/home/tt/.rvm/gems/ruby-2.0.0-p648/gems/google-api-client-0.13.0/lib/google/apis/core/http_command.rb:218:in check_status': Invalid request (Google::Apis::ClientError) from /home/tt/.rvm/gems/ruby-2.0.0-p648/gems/google-api-client-0.13.0/lib/google/apis/core/api_command.rb:116:in check_status'
from /home/tt/.rvm/gems/ruby-2.0.0-p648/gems/google-api-client-0.13.0/lib/google/apis/core/download.rb:103:in execute_once' from /home/tt/.rvm/gems/ruby-2.0.0-p648/gems/google-api-client-0.13.0/lib/google/apis/core/http_command.rb:104:in block (2 levels) in execute'
from /home/tt/.rvm/gems/ruby-2.0.0-p648/gems/retriable-3.0.1/lib/retriable.rb:50:in block in retriable' from /home/tt/.rvm/gems/ruby-2.0.0-p648/gems/retriable-3.0.1/lib/retriable.rb:46:in times'
from /home/tt/.rvm/gems/ruby-2.0.0-p648/gems/retriable-3.0.1/lib/retriable.rb:46:in retriable' from /home/tt/.rvm/gems/ruby-2.0.0-p648/gems/google-api-client-0.13.0/lib/google/apis/core/http_command.rb:101:in block in execute'
from /home/tt/.rvm/gems/ruby-2.0.0-p648/gems/retriable-3.0.1/lib/retriable.rb:50:in block in retriable' from /home/tt/.rvm/gems/ruby-2.0.0-p648/gems/retriable-3.0.1/lib/retriable.rb:46:in times'
from /home/tt/.rvm/gems/ruby-2.0.0-p648/gems/retriable-3.0.1/lib/retriable.rb:46:in retriable' from /home/tt/.rvm/gems/ruby-2.0.0-p648/gems/google-api-client-0.13.0/lib/google/apis/core/http_command.rb:93:in execute'
from /home/tt/.rvm/gems/ruby-2.0.0-p648/gems/google-api-client-0.13.0/lib/google/apis/core/base_service.rb:360:in execute_or_queue_command' from /home/tt/.rvm/gems/ruby-2.0.0-p648/gems/google-api-client-0.13.0/generated/google/apis/drive_v3/service.rb:740:in export_file'
from read_from_drive.rb:57:in download_file' from read_from_drive.rb:52:in initialize_api'
from read_from_drive.rb:84:in `

'

As per your documentation:
For downloads, the download_dest parameter can also be either a path to a file, an IO stream, or StringIO instance.

@tombroomfield
Copy link

Hi, did you find a solution to this?

@MoCengage
Copy link

MoCengage commented Jul 25, 2017

I'm having the same issue; trying Google API for first time. I can't seem to get the export_file to work.

NVM was able to resolve my issue. PEBCAK!

@sqrrrl sqrrrl added Priority: P2+ type: question Request for information or clarification. Not an issue. labels Aug 3, 2017
@sqrrrl sqrrrl self-assigned this Aug 3, 2017
@sqrrrl
Copy link
Contributor

sqrrrl commented Aug 3, 2017

Error is that the request is invalid, likely because you're using an unsupported mime type.

List of valid conversions are here:
https://developers.google.com/drive/v3/web/manage-downloads

@sqrrrl sqrrrl closed this as completed Aug 3, 2017
@Himanshu-Lakra
Copy link

Hi @sqrrrl
I used same mime type for getting file_id and it works for me
response = drive_service.list_files(q: "name='#{file_name}' and mimeType='application/vnd.ms-excel'",
spaces: 'drive',
fields:'nextPageToken, files(id, name)',
page_token: page_token)

so are there different mime types supported for different google drive api's (eg. export, search) ?

@syakovyn
Copy link

Most likely it is related to #906

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

6 participants