heroku - How to serve S3 files from a Rails app? -


i trying allow users download s3 file left clicking link. normally, have right-clicking , save-as.

i looked http://apidock.com/rails/actioncontroller/datastreaming/send_file not sure if want.

this article http://www.jtricks.com/bits/content_disposition.html shows how can done configuring apache. however, using heroku.

anyone used content-disposition before serve files s3? wondering if takes whole web process (dyno)? or if whole process happens on s3 server instead?

i tried:

send_file 'http://some_bucket_name.s3.amazonaws.com/uploads/users/28/songs/88/test.mp3', :type => 'audio/mp3', :disposition => 'attachment' 

and get:

cannot read file http://some_bucket_name.s3.amazonaws.com/uploads/users/28/songs/88/test.mp3 

the file exist. if manually navigate url. file plays fine.

this works rails 3. in controller do:

response.headers['content-disposition'] = "attachment; filename=#{original_filename}" self.response_body = proc { |response, output|   aws::s3::s3object.stream(path, 'some_bucket_name') { |segment|     output.write segment   } } 

in case:

original_filename = 'test.mp3' path = '/uploads/users/28/songs/88/test.mp3' 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -