Method: Google::Cloud::Storage.new
- Defined in:
- lib/google/cloud/storage.rb
.new(project: nil, keyfile: nil, scope: nil, retries: nil, timeout: nil) ⇒ Google::Cloud::Storage::Project
Creates a new object for connecting to the Storage service. Each call creates a new connection.
For more information on connecting to Google Cloud see the Authentication Guide.
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
# File 'lib/google/cloud/storage.rb', line 447 def self.new project: nil, keyfile: nil, scope: nil, retries: nil, timeout: nil project ||= Google::Cloud::Storage::Project.default_project project = project.to_s # Always cast to a string fail ArgumentError, "project is missing" if project.empty? if keyfile.nil? credentials = Google::Cloud::Storage::Credentials.default scope: scope else credentials = Google::Cloud::Storage::Credentials.new( keyfile, scope: scope) end Google::Cloud::Storage::Project.new( Google::Cloud::Storage::Service.new( project, credentials, retries: retries, timeout: timeout)) end |