I have done a very similar thing to this, allowing people to upload an
image
from either their hard drive or an image from a url, I used file column
to
handle the validations on both, but I have to do some tweaks on the URL
image before I save it to the file column, when you upload any file to a
cgi
server it is kept in the servers temp dir until you do something with
it,
knowing this you can tweak hat file until you need it
so one trick could be to upload your own temp img, without using
file_column
for the upload, validate it then copy it to the file column if it
validates
(file column does this but you want access to ‘your’ own temp file)
to do this don’t use the file_column helper to upload, just use the
basic
rails helper or just write it in html
this is what file_column does in the background, so do something similar
for
the field ‘img_name’ in the model ‘tile’
this is a bit of a hack, but create another column in your img db
table called img2 or something and use this for storing the temp image
e.g
you need to do this because as soon as FileColumn sees anything
initilised
to its column img_name it will grab it and run with it…
then in your upload action, create an instance with the params
@tile = Tile.new(params[:tile])
@tile.img_name2 should be pointing to the temp img
validate the temp img, as you please, it is stored as a TempFile in the
servers file systems temp directory
if it all checks out…copy the temp image to the file_column using the
system commands in FileUtils, add require ‘fileutils’ to your rails app
to
use this
I can give you a better example later on when I get home, I was doing a
similar sort of thing last night and did not commit the code to my svn
so
cant have a look at it right now…
hope this gets you going in the right direction
dion
www.blogsaic.com