Sha256: 062600728002d364c853696cdaafe37ceb499f845123e8d52520a74c9e389d04

Contents?: true

Size: 512 Bytes

Versions: 5

Compression:

Stored size: 512 Bytes

Contents

require 'google/cloud/storage'

require 'yardi/utils'

module Yardi
  module Utils
    class GoogleCloudStorage
      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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yardi-4.11.4 lib/yardi/utils/google_cloud_storage.rb
yardi-4.11.3 lib/yardi/utils/google_cloud_storage.rb
yardi-5.0.1 lib/yardi/utils/google_cloud_storage.rb
yardi-4.11.2 lib/yardi/utils/google_cloud_storage.rb
yardi-4.11.1 lib/yardi/utils/google_cloud_storage.rb