diff --git a/NEWS.md b/NEWS.md index 0bcd48e1fc9c..b026f463bb2e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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) ------------------- diff --git a/services/datasources/lib/datasources/url/gdrive.rb b/services/datasources/lib/datasources/url/gdrive.rb index e13384671c6d..5d5272726a50 100644 --- a/services/datasources/lib/datasources/url/gdrive.rb +++ b/services/datasources/lib/datasources/url/gdrive.rb @@ -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