Hi, I store files on S3 as the id of the file in my appliction. IE my file with id 20 will be stored on S3 as 20. When I download the file I want to look up the file name in the database and then pass it off to the user. Is there any way I can use redirect_to and pass the S3 url and then give it the filename, so the user doesn''t get 20. Does this make sense? Thanks, David -- Posted via http://www.ruby-forum.com/.
On Sat, Aug 1, 2009 at 5:31 PM, David Smit<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I store files on S3 as the id of the file in my appliction. IE my file > with id 20 will be stored on S3 as 20. When I download the file I want > to look up the file name in the database and then pass it off to the > user. Is there any way I can use redirect_to and pass the S3 url and > then give it the filename, so the user doesn''t get 20. > > Does this make sense?Yes: set the Content-Disposition header when you upload to S3. jeremy
Jeremy Kemper wrote:> On Sat, Aug 1, 2009 at 5:31 PM, David > Smit<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> I store files on S3 as the id of the file in my appliction. IE my file >> with id 20 will be stored on S3 as 20. When I download the file I want >> to look up the file name in the database and then pass it off to the >> user. Is there any way I can use redirect_to and pass the S3 url and >> then give it the filename, so the user doesn''t get 20. >> >> Does this make sense? > > Yes: set the Content-Disposition header when you upload to S3. > > jeremyYes, but when it I redirect the users to the url, the filename is still 20 and not mypicture.jpg. -- Posted via http://www.ruby-forum.com/.
On Sat, Aug 1, 2009 at 5:43 PM, David Smit<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Jeremy Kemper wrote: >> On Sat, Aug 1, 2009 at 5:31 PM, David >> Smit<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >>> I store files on S3 as the id of the file in my appliction. IE my file >>> with id 20 will be stored on S3 as 20. When I download the file I want >>> to look up the file name in the database and then pass it off to the >>> user. Is there any way I can use redirect_to and pass the S3 url and >>> then give it the filename, so the user doesn''t get 20. >>> >>> Does this make sense? >> >> Yes: set the Content-Disposition header when you upload to S3. >> >> jeremy > > Yes, but when it I redirect the users to the url, the filename is still > 20 and not mypicture.jpg.The URL ends in 20, yes, but Content-Disposition: attachment; filename="mypicture.jpg" tells the browser to download a file named mypicture.jpg. Do some googling on the topic and you''ll find many others with the same scenario and solution. jeremy