Module: MultiVideoStreaming::Utils::S3

Defined in:
lib/multi_video_streaming/utils/s3/generate_presign_url.rb

Class Method Summary collapse

Class Method Details

.generate_presign_url(method:, bucket:, key:) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/multi_video_streaming/utils/s3/generate_presign_url.rb', line 6

def self.generate_presign_url(method:, bucket:, key:)
  methods = { :get => :get_object, :put => :put_object, :delete => :delete_object }
  method_to_generate_presign_url = methods[method]
  raise MultiVideoStreaming::Errors::InvalidS3MethodName.new(method) if method_to_generate_presign_url.nil?
  signer = Aws::S3::Presigner.new
  signer.presigned_url(method_to_generate_presign_url, bucket: bucket, key: key, expires_in: 900)
end