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

[ch113786] Replace 'export_file' by 'http' to download Google Sheet files #15903

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Development
* Fix Dashboard/Data navigation for free users. Update Data preview texts [#15892](https://github.com/CartoDB/cartodb/pull/15892)
* Force CTE materialization in Ghost Tables query to improve performance [#15895](https://github.com/CartoDB/cartodb/pull/15895)
* Adapt default Rails mail logs to JSON format [#15894](https://github.com/CartoDB/cartodb/pull/15894)
* Fix export of Google Sheet files larger than 10MB [#15903](https://github.com/CartoDB/cartodb/pull/15903)

4.42.0 (2020-09-28)
-------------------
Expand Down
15 changes: 9 additions & 6 deletions services/datasources/lib/datasources/url/gdrive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,22 +193,25 @@ def get_resource(id)
raise DataDownloadError.new(error_msg, DATASOURCE_NAME)
end
if file.export_links.present?
@drive.export_file(file.id, 'text/csv', download_dest: StringIO.new) do |content, export_err|
@drive.http(:get, file.export_links['text/csv'], download_dest: StringIO.new) do |content, export_err|
raise export_err if export_err
return content

# NOTE: Reinitializing StringIO due to 'content' is not readable
return StringIO.new(content.string)
end
else
@drive.get_file(file.id, download_dest: StringIO.new) do |content, download_err|
raise download_err if download_err

return content
end
end
end
rescue Google::Apis::AuthorizationError, Signet::AuthorizationError => ex
raise TokenExpiredOrInvalidError.new("Invalid token: #{ex.message}", DATASOURCE_NAME)
rescue Google::Apis::AuthorizationError, Signet::AuthorizationError => e
raise TokenExpiredOrInvalidError.new("Invalid token: #{e.message}", DATASOURCE_NAME)
rescue Google::Apis::BatchError, Google::Apis::TransmissionError, Google::Apis::ClientError, \
Google::Apis::ServerError => ex
raise DataDownloadError.new("downloading file #{id}: #{ex.message}", DATASOURCE_NAME)
Google::Apis::ServerError => e
raise DataDownloadError.new("downloading file #{id}: #{e.message}", DATASOURCE_NAME)
end

# @param id string
Expand Down