# Redirect\_to or send\_file and AWS S3

**URL:** <https://www.ruby-forum.com/t/redirect-to-or-send-file-and-aws-s3/173086>\
**Category:** Rails\
**Created:** [August 2, 2009, 2:31am UTC](https://www.ruby-forum.com/t/redirect-to-or-send-file-and-aws-s3/173086 "2009-08-02T02:31:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [August 2, 2009, 2:31am UTC](https://www.ruby-forum.com/t/redirect-to-or-send-file-and-aws-s3/173086/1 "2009-08-02T02:31:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [August 2, 2009, 2:39am UTC](https://www.ruby-forum.com/t/redirect-to-or-send-file-and-aws-s3/173086/2 "2009-08-02T02:39:44Z")

</div>

On Sat, Aug 1, 2009 at 5:31 PM, David  
Smit[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [August 2, 2009, 2:43am UTC](https://www.ruby-forum.com/t/redirect-to-or-send-file-and-aws-s3/173086/3 "2009-08-02T02:43:55Z")

</div>

Jeremy K. wrote:

> On Sat, Aug 1, 2009 at 5:31 PM, David  
> Smit[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [August 2, 2009, 4:36am UTC](https://www.ruby-forum.com/t/redirect-to-or-send-file-and-aws-s3/173086/4 "2009-08-02T04:36:48Z")

</div>

On Sat, Aug 1, 2009 at 5:43 PM, David  
Smit[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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
