Class: ActiveStorage::Service::VstorageService

Inherits:
S3Service
  • Object
show all
Defined in:
lib/active_storage/service/vstorage_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bucket:, upload: {}, public: false, **options) ⇒ VstorageService

Returns a new instance of VstorageService.



15
16
17
18
19
20
21
22
23
# File 'lib/active_storage/service/vstorage_service.rb', line 15

def initialize(bucket:, upload: {}, public: false, **options)
  @region = options[:region].downcase
  @project_id = upload.delete(:project_id)
  @client_id = upload.delete(:client_id)
  @client_secret = upload.delete(:client_secret)
  @authorization = Base64.strict_encode64("#{@client_id}:#{@client_secret}")

  super(bucket: bucket, upload: upload, public: public, **options)
end

Instance Attribute Details

#authorizationObject (readonly)

Returns the value of attribute authorization.



9
10
11
# File 'lib/active_storage/service/vstorage_service.rb', line 9

def authorization
  @authorization
end

#client_idObject (readonly)

Returns the value of attribute client_id.



9
10
11
# File 'lib/active_storage/service/vstorage_service.rb', line 9

def client_id
  @client_id
end

#client_secretObject (readonly)

Returns the value of attribute client_secret.



9
10
11
# File 'lib/active_storage/service/vstorage_service.rb', line 9

def client_secret
  @client_secret
end

#project_idObject (readonly)

Returns the value of attribute project_id.



9
10
11
# File 'lib/active_storage/service/vstorage_service.rb', line 9

def project_id
  @project_id
end

#regionObject (readonly)

Returns the value of attribute region.



9
10
11
# File 'lib/active_storage/service/vstorage_service.rb', line 9

def region
  @region
end

Instance Method Details

#url_for_direct_upload(key, expires_in:) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/active_storage/service/vstorage_service.rb', line 25

def url_for_direct_upload(key, expires_in:, **)
  instrument(:url, key: key) do |payload|
    generated_url = temp_url(bucket, key, expires_in)
    payload[:url] = generated_url
    generated_url
  end
end