# Images outside the site

**URL:** <https://www.ruby-forum.com/t/images-outside-the-site/107133>\
**Category:** Rails\
**Created:** [June 18, 2007, 2:28pm UTC](https://www.ruby-forum.com/t/images-outside-the-site/107133 "2007-06-18T14:28:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hotgazpacho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a587f6/32.png) [@hotgazpacho](https://www.ruby-forum.com/u/hotgazpacho)\
**Post date:** [June 18, 2007, 2:28pm UTC](https://www.ruby-forum.com/t/images-outside-the-site/107133/1 "2007-06-18T14:28:57Z")

</div>

I’m developing a site that will need to display images that will be  
stored in a location outside the site. What would be the easiest way to  
do this? The site will be running on a linux machine.

Thanks,  
Will

* * *

You snooze, you lose. Get messages ASAP with AutoCheck  
in the all-new Yahoo! Mail Beta.

---

<div class="post-metadata">

**Author:** ![hotgazpacho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a587f6/32.png) [@hotgazpacho](https://www.ruby-forum.com/u/hotgazpacho)\
**Post date:** [June 18, 2007, 7:41pm UTC](https://www.ruby-forum.com/t/images-outside-the-site/107133/2 "2007-06-18T19:41:47Z")

</div>

[ 
- BD

](http://www.some-external-site.com/images/some-img.jpg)

---

<div class="post-metadata">

**Author:** ![hotgazpacho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a587f6/32.png) [@hotgazpacho](https://www.ruby-forum.com/u/hotgazpacho)\
**Post date:** [June 18, 2007, 7:52pm UTC](https://www.ruby-forum.com/t/images-outside-the-site/107133/3 "2007-06-18T19:52:49Z")

</div>

Actually, the images in question need to be stored in the filesystem  
outside the site, but I’d rather not expose them to the web. The flow of  
operations I’d like to have is as follows:

1. User requests an image, sending the image id. Under the hood, it hits  
a controller method, so the request would be something like  
([http://mysite.com/images/getbinary/152](http://mysite.com/images/getbinary/152)).
2. My system picks up the id from the request and locates the image on  
disk
3. Some component of rails grabs the image from disk and pushes down to  
the client.

For instance, in .NET I’d probably create an Image object, load it from  
the image on disk, then serialize it into the response stream. That way,  
the image would only be available to the user through the site.

Brian D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

- BD

On Jun 18, 7:27 am, Will G. wrote:

> I’m developing a site that will need to display images that will be stored in a location outside the site. What would be the easiest way to do this? The site will be running on a linux machine.
> 
> Thanks,  
> Will
> 
> * * *
> 
> You snooze, you lose. Get messages ASAP with AutoCheck  
> in the all-new Yahoo! Mail Beta.

* * *

Get the Yahoo! toolbar and be alerted to new email wherever you’re  
surfing.

---

<div class="post-metadata">

**Author:** ![hotgazpacho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a587f6/32.png) [@hotgazpacho](https://www.ruby-forum.com/u/hotgazpacho)\
**Post date:** [June 18, 2007, 8:39pm UTC](https://www.ruby-forum.com/t/images-outside-the-site/107133/4 "2007-06-18T20:39:00Z")

</div>

That’s exactly what I needed. Thank you!

Rob B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote: Look at send\_file()

```
send_file( '/path/to/some/image_file.gif',
           :disposition => 'inline',
           :type => 'image/gif',
           :stream => false,
           :filename => 'private_file.gif' )

```

-Rob

On Jun 18, 2007, at 1:52 PM, Will G. wrote:

Actually, the images in question need to be stored in the filesystem  
outside the site, but I’d rather not expose them to the web. The flow of  
operations I’d like to have is as follows:

1. User requests an image, sending the image id. Under the hood, it hits  
a controller method, so the request would be something like  
([http://mysite.com/images/getbinary/152](http://mysite.com/images/getbinary/152)).
2. My system picks up the id from the request and locates the image on  
disk
3. Some component of rails grabs the image from disk and pushes down to  
the client.

For instance, in .NET I’d probably create an Image object, load it from  
the image on disk, then serialize it into the response stream. That way,  
the image would only be available to the user through the site.

Brian D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

- BD

On Jun 18, 7:27 am, Will G. wrote:

> I’m developing a site that will need to display images that will be stored in a location outside the site. What would be the easiest way to do this? The site will be running on a linux machine.
> 
> Thanks,  
> Will
> 
> * * *
> 
> You snooze, you lose. Get messages ASAP with AutoCheck  
> in the all-new Yahoo! Mail Beta.

* * *

Get the Yahoo! toolbar and be alerted to new email wherever you’re  
surfing.

* * *

Choose the right car based on your needs. Check out Yahoo! Autos new  
Car Finder tool.

---

<div class="post-metadata">

**Author:** ![hotgazpacho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a587f6/32.png) [@hotgazpacho](https://www.ruby-forum.com/u/hotgazpacho)\
**Post date:** [June 18, 2007, 8:23pm UTC](https://www.ruby-forum.com/t/images-outside-the-site/107133/5 "2007-06-18T20:23:56Z")

</div>

Look at send\_file()

```
 send_file( '/path/to/some/image_file.gif',
            :disposition => 'inline',
            :type => 'image/gif',
            :stream => false,
            :filename => 'private_file.gif' )

```

-Rob
