Redirect_to or send_file and AWS S3

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

On Sat, Aug 1, 2009 at 5:31 PM, David
Smit[email protected] 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 K. wrote:

On Sat, Aug 1, 2009 at 5:31 PM, David
Smit[email protected] 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.

On Sat, Aug 1, 2009 at 5:43 PM, David
Smit[email protected] wrote:

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