Class: Yardi::Utils::GoogleCloudStorage

Inherits:
Object
  • Object
show all
Defined in:
lib/yardi/utils/google_cloud_storage.rb

Class Method Summary collapse

Class Method Details

.clientObject



20
21
22
# File 'lib/yardi/utils/google_cloud_storage.rb', line 20

def self.client
  @client ||= Google::Cloud::Storage.new
end

.read_file(file_path:, bucket: Yardi.config.gcs_bucket) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/yardi/utils/google_cloud_storage.rb', line 8

def self.read_file(file_path:, bucket: Yardi.config.gcs_bucket)
  bucket = client.bucket(bucket)
  file = bucket.file(file_path)
  if file
    downloaded = file.download
    downloaded.rewind
    downloaded.read
  else
    ''
  end
end