Class: Gitlab::Database::Capture::StorageConnectors::Gcs

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/database/capture/storage_connectors/gcs.rb

Overview

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ Gcs

Returns a new instance of Gcs.



12
13
14
# File 'lib/gitlab/database/capture/storage_connectors/gcs.rb', line 12

def initialize(settings)
  @settings = settings
end

Instance Method Details

#upload(filename, data) ⇒ Object

We have to escape “/” from the filename to avoid gcp to interpret as a subfolder. This can be a problem if we use the primary write location compose the filename, which can include an address like “1F/4BE69098”



18
19
20
21
22
23
24
25
26
27
# File 'lib/gitlab/database/capture/storage_connectors/gcs.rb', line 18

def upload(filename, data)
  bucket.create_file(
    StringIO.new(data),
    CGI.escape(filename),
    metadata: {
      original_filename: filename,
      encoded: true
    }
  )
end