9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/send_s3_file.rb', line 9
def send_s3_file file_name, bucket, options = {}
s3 = AWS::S3.new
object = s3.buckets[bucket].objects[file_name]
.merge!(
'Content-Type' => build_content_type(options),
'Content-Disposition' => build_disposition(options),
'Content-Transfer-Encoding' => 'binary'
)
render :status => options[:status], :text => Proc.new {|response, output|
logger.info "Streaming file from s3 #{bucket} #{file_name}" unless logger.nil?
object.read do |chunk|
output.write(chunk)
end
logger.info "Done Streaming file from s3 #{bucket} #{file_name}" unless logger.nil?
}
end
|