Module: ActiveStorage::Crucible::PresignedUrl

Defined in:
lib/active_storage/crucible/presigned_url.rb

Class Method Summary collapse

Class Method Details

.for(blob, method: :put, expires_in: 1.hour) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/active_storage/crucible/presigned_url.rb', line 6

def self.for(blob, method: :put, expires_in: 1.hour)
  case method
  when :get
    blob.url(expires_in: expires_in)
  when :put
    service = blob.service
    object = service.send(:object_for, blob.key)
    object.presigned_url(:put, expires_in: expires_in.to_i, content_type: blob.content_type)
  end
end