Module: Google::Cloud::Gemserver::GCS

Defined in:
lib/google/cloud/gemserver/gcs.rb

Overview

Google Cloud Storage

Interacts with Google Cloud Storage by providing methods that upload and download files to and from Google Cloud Storage.

Class Method Summary collapse

Class Method Details

.delete_file(file) ⇒ Object

Deletes a given file from Google Cloud Storage.

Parameters:

  • file (String)

    Name of the file to be deleted.



90
91
92
93
# File 'lib/google/cloud/gemserver/gcs.rb', line 90

def self.delete_file file
  return unless proj_id
  get_file(file).delete
end

.get_file(file) ⇒ Google::Cloud::Storage::File

Retrieves a file from Google Cloud Storage from a project's corresponding bucket.

Parameters:

  • file (String)

    Name of the file to be retrieved.

Returns:

  • (Google::Cloud::Storage::File)


66
67
68
69
# File 'lib/google/cloud/gemserver/gcs.rb', line 66

def self.get_file file
  return unless proj_id
  bucket.file file
end

.upload(file, dest = nil) ⇒ Google::Cloud::Storage::File

Uploads a given file to a project's corresponding bucket on Google Cloud Storage. A destination path of the file can be provided. By default the path of the file is the same on Google Cloud Storage.

Storage. Optional.

Parameters:

  • file (String)

    Path to the file to be uploaded.

  • dest (String) (defaults to: nil)

    Destination path of the file on Google Cloud

Returns:

  • (Google::Cloud::Storage::File)


81
82
83
84
# File 'lib/google/cloud/gemserver/gcs.rb', line 81

def self.upload file, dest = nil
  return unless proj_id
  bucket.create_file file, dest
end