# Understanding Image Uploads

**URL:** <https://www.ruby-forum.com/t/understanding-image-uploads/66941>\
**Category:** Rails\
**Created:** [August 30, 2006, 2:39pm UTC](https://www.ruby-forum.com/t/understanding-image-uploads/66941 "2006-08-30T14:39:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 30, 2006, 2:39pm UTC](https://www.ruby-forum.com/t/understanding-image-uploads/66941/1 "2006-08-30T14:39:05Z")

</div>

Hi, I’m starting to look at uploading images to a web database.

I understand that the first thing I need to use is file\_column so that  
the images are not stored in the database itself, but in the file  
system. Would I be right in saying that adding security to it  
(protecting it from prying eyes) would only be a matter of adding a  
before\_filter to the system?

My other main problem is regarding integration of this web database with  
my Windows application. I want to do something like Picasa (I guess)  
where people can partially edit the picture on their PC and then click  
upload to send it to their web album. Does anyone have any references  
on how data is transferred over HTTP to send and receive image files?  
I’m reading this right now:  
[http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1](http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1)  
but if someone has a better reference, I’d seriously appreciate it.

Thanks,  
Mohit.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 30, 2006, 2:51pm UTC](https://www.ruby-forum.com/t/understanding-image-uploads/66941/2 "2006-08-30T14:51:07Z")

</div>

On 8/30/06, Mohit S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi, I’m starting to look at uploading images to a web database.

What’s a web database ?

> I understand that the first thing I need to use is file\_column so that  
> the images are not stored in the database itself, but in the file  
> system. Would I be right in saying that adding security to it  
> (protecting it from prying eyes) would only be a matter of adding a  
> before\_filter to the system?

No. You have to store images outside RAILS\_ROOT/public and use  
send\_file from controller after validating access.

> My other main problem is regarding integration of this web database with  
> my Windows application. I want to do something like Picasa (I guess)  
> where people can partially edit the picture on their PC and then click  
> upload to send it to their web album. Does anyone have any references  
> on how data is transferred over HTTP to send and receive image files?  
> I’m reading this right now:  
> [Forms in HTML documents](http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1)  
> but if someone has a better reference, I’d seriously appreciate it.

You can probably try to use rmagick’s to\_blob function, then use Zlib  
for compression and base 64 encode the data before transferring. But  
I’m not sure if that’d improve the performance or not, logically it  
should. You can use multipart post form for uploading and proper  
content-type in http header for downloading the image.

> Thanks,  
> Mohit.
> 
> >

–  
rm -rf / 2\>/dev/null - [http://null.in](http://null.in)

Dont judge those who try and fail, judge those who fail to try…

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 30, 2006, 2:57pm UTC](https://www.ruby-forum.com/t/understanding-image-uploads/66941/3 "2006-08-30T14:57:08Z")

</div>

just for your info: file\_column seems to be abandoned, but theres an  
acts\_as\_attachement plugin, too

2006/8/30, Mohit S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> My other main problem is regarding integration of this web database with
> 
> >

–  
Michael S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

[www.siebert-wd.de](http://www.siebert-wd.de) - Gedanken lesen  
[www.stellar-legends.de](http://www.stellar-legends.de) - Weltraum-Browsergame im Alpha-Stadium

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 30, 2006, 3:11pm UTC](https://www.ruby-forum.com/t/understanding-image-uploads/66941/4 "2006-08-30T15:11:08Z")

</div>

Thanks Michael… that changes things - somehow, after all the talk of  
file\_column that I have seen, I just expected it to be around 🙂

Cheers  
Mohit.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 30, 2006, 3:09pm UTC](https://www.ruby-forum.com/t/understanding-image-uploads/66941/5 "2006-08-30T15:09:08Z")

</div>

Hi Pratik,

Thanks for your response. My answers inline…

Pratik wrote:

> On 8/30/06, Mohit S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Hi, I’m starting to look at uploading images to a web database.
> 
> What’s a web database ?

Sorry, I should have termed it better - I did mean a web-enabled  
database. So, basically a MySQL database with a Rails app!

> 

Hmm, OK. Thanks for the pointer, will need to look into this!

> You can probably try to use rmagick’s to\_blob function, then use Zlib  
> for compression and base 64 encode the data before transferring. But  
> I’m not sure if that’d improve the performance or not, logically it  
> should. You can use multipart post form for uploading and proper  
> content-type in http header for downloading the image.

Hmm… In my case, the client is a C++ program that runs under Windows,  
so I’m going to have do most of that myself, I guess… But, if I  
understand you correctly, what’s needed is compression → base64 encode  
and use a multipart form and proper content-typing…

Hmm, a bit of a handful, but thanks for the pointers… time to start  
looking at these things then!

Cheers  
Mohit.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 31, 2006, 8:35am UTC](https://www.ruby-forum.com/t/understanding-image-uploads/66941/6 "2006-08-31T08:35:04Z")

</div>

Nonsense.

File column is around and still kicking ass. 🙂 It may not  
be under massivelly heavy development, but what more does it need?  
It’s had some new features added this year, and it certainly makes  
image manipulation stuff (with rmagic) really easy. I’m using it for a  
number of production sites, with great success.

regards,

Craig  
[www.craigambrose.com](http://www.craigambrose.com)

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 31, 2006, 9:03am UTC](https://www.ruby-forum.com/t/understanding-image-uploads/66941/7 "2006-08-31T09:03:07Z")

</div>

I use file\_column…it works

check out my site [http://www.blogsaic.com/](http://www.blogsaic.com/)

upload some tiles

play around in your account, change the image for tiles you have already  
uploaded

you will see that file\_column is pretty handy, simple

cheers

dion

On 8/31/06, Craig A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> regards,
> 
> Craig  
> [www.craigambrose.com](http://www.craigambrose.com)
> 
> > Michael S. wrote:  
> > just for your info: file\_column seems to be abandoned, but theres an  
> > acts\_as\_attachement plugin, too
> 
> >

–

[www.blogsaic.com](http://www.blogsaic.com)  
search, post, blog

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 31, 2006, 6:12pm UTC](https://www.ruby-forum.com/t/understanding-image-uploads/66941/8 "2006-08-31T18:12:29Z")

</div>

Craig A. wrote:

> Craig  
> [www.craigambrose.com](http://www.craigambrose.com)

I can sum up my emotion in one word: PHEW!  
🙂  
Cheers  
Mohit.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 31, 2006, 6:22pm UTC](https://www.ruby-forum.com/t/understanding-image-uploads/66941/9 "2006-08-31T18:22:31Z")

</div>

Dion H. wrote:

> cheers
> 
> dion

Thanks Dion!  
Cheers  
Mohit.
