Class: AppProfiler::Storage::GoogleCloudStorage

Inherits:
BaseStorage
  • Object
show all
Defined in:
lib/app_profiler/storage/google_cloud_storage.rb

Constant Summary collapse

GOOGLE_SCOPE =
"https://www.googleapis.com/auth/devstorage.read_write"

Class Method Summary collapse

Class Method Details

.upload(profile, _params = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/app_profiler/storage/google_cloud_storage.rb', line 15

def upload(profile, _params = {})
  file = profile.file.open

  ActiveSupport::Notifications.instrument(
    "gcs_upload.app_profiler",
    file_size: file.size,
  ) do
    bucket.create_file(
      StringIO.new(gzipped_reader(file).read),
      gcs_filename(profile),
      content_type: "application/json",
      content_encoding: "gzip",
    )
  end
end