lib/google/cloud/bigquery/service.rb in google-cloud-bigquery-1.13.0 vs lib/google/cloud/bigquery/service.rb in google-cloud-bigquery-1.14.0
- old
+ new
@@ -17,11 +17,11 @@
require "google/cloud/bigquery/convert"
require "google/cloud/errors"
require "google/apis/bigquery_v2"
require "pathname"
require "securerandom"
-require "mime/types"
+require "mini_mime"
require "date"
module Google
module Cloud
module Bigquery
@@ -37,19 +37,21 @@
# @private
attr_accessor :credentials
# @private
- attr_reader :retries, :timeout
+ attr_reader :retries, :timeout, :host
##
# Creates a new Service instance.
- def initialize project, credentials, retries: nil, timeout: nil
+ def initialize project, credentials,
+ retries: nil, timeout: nil, host: nil
@project = project
@credentials = credentials
@retries = retries
@timeout = timeout
+ @host = host
end
def service
return mocked_service if mocked_service
@service ||= begin
@@ -63,10 +65,11 @@
service.request_options.retries = 0 # handle retries in #execute
service.request_options.header ||= {}
service.request_options.header["x-goog-api-client"] = \
"gl-ruby/#{RUBY_VERSION} gccl/#{Google::Cloud::Bigquery::VERSION}"
service.authorization = @credentials.client
+ service.root_url = host if host
service
end
end
attr_accessor :mocked_service
@@ -478,12 +481,12 @@
def generate_id
SecureRandom.urlsafe_base64 21
end
def mime_type_for file
- mime_type = MIME::Types.of(Pathname(file).to_path).first.to_s
- return nil if mime_type.empty?
- mime_type
+ mime_type = MiniMime.lookup_by_filename Pathname(file).to_path
+ return nil if mime_type.nil?
+ mime_type.content_type
rescue StandardError
nil
end
def execute backoff: nil