Module: S3ReproxyDownload::Helper

Defined in:
lib/s3_reproxy_download.rb

Instance Method Summary collapse

Instance Method Details

#send_s3_file(bucket_name, path, headers: {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/s3_reproxy_download.rb', line 15

def send_s3_file(bucket_name, path, headers: {})
  s3_object = S3ReproxyDownload::S3Object.new(bucket_name, path)

  response.headers['X-Accel-Redirect'] = S3ReproxyDownload.reproxy_path
  response.headers['X-Reproxy-URL'] = s3_object.presigned_url
  response.headers['Content-Disposition'] = "attachment; filename=\"#{s3_object.filename}\""

  headers.each do |header, value|
    response.headers[header] = value
  end

  head :ok
end