Forum: Ruby on Rails file_column 0.3.1 with SVN repository

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B8ed55487e4f2f0feaeb68957dc07b21?d=identicon&s=25 skanthak (Guest)
on 2005-11-15 01:35
(Received via mailing list)
Hi there,

I'm happy to announce a new minor release of file_column. It contains
two small fixes.

* You can now serialize objects that have a file_column again, which
is important if you want to store these objects into the flash or the
session.

* If you want to use the RMagick integration and you've installed
RMagick yourself (instead of as a gem) it should work right out of the
box.


Apart from these fixes, the plugin is finally available at a public
svn repository, so that you can use the cool new plugin script, rails
features in its latest release candidate. The repository is at:

https://opensvn.csie.org/rails_file_column/plugins...

Installation is as easy as typing

./script/plugin install
https://opensvn.csie.org/rails_file_column/plugins...

(you can still get an archive at
http://www.kanthak.net/opensource/file_column/)

in your project's directory. Warning: The trunk can be unstable. You
can find stable releases in the tags directory. Is there a standard
way of telling the plugin script about which version to use? I'm a bit
confused here, because the standard layout of plugin repositories does
not seem to contain the standard tags or branches directories. Can
somebody educate me about the repository conventions for plugins? How
do you make sure as a plugin developer, that your users only use
stable versions by default?


On a different note, I need some input on the future directions of
file_column, so that it suits your needs as well as possible. I have
already discussed some of these ideas with Kyle Maxwell. Thanks a lot
for your input, Kyle!

Basically I want to keep file_column as lean and general as possible,
while providing some more features that have been requested often and
making it easy for you to implement your more exotic needs. So here
are two points, where I'd be happy about feedback:

* Right now, I'm using the RMagick library to use the imagemagick
toolkit. Is it hard to get this working under Windows? Would you
prefer file_column calling the imagemagick commands directly? I'd like
to keep the dependency on the RMagick library as it allows for much
more beautiful code and easier handling of images.

* The versions feature allows you to declare in the model, that
several different sizes of an image should be stored that can
subsequently be accessed from your view. Kyle and I feel that this
information doesn't really belong into the model, so Kyle suggested
that you can specify a geometry string in the view's
url_for_file_column method. If an image does not exist in these
dimensions already, it will be created transparently and stored so
that it can be used again in the next request.

What do you think about this feature? Does it make sense? Should it
replace the declaration of versions in the model completely or should
it be an additional feature?


Thanks for all the encouranging feedback I have received so far!

Sebastian
A7db9ec803b5895ae5f916a74e2db329?d=identicon&s=25 lists (Guest)
on 2005-11-15 01:53
(Received via mailing list)
The plus side is that if you add a new size, you don't have to re-input
the
images to get the new sizes.

I think that this is a great idea as long as the images are generated
only
if they don't already exist. Having to call ImageMagick for every
request
would kill performance for us on the 5MM/month page view site we are
developing.

The thing I like about having it in the model is that I don't have to
type
that geometry string all over... DRY and all that good stuff.
648d60296e65a1278017c0b9f960ec3a?d=identicon&s=25 ol1barn3s (Guest)
on 2005-11-15 03:45
(Received via mailing list)
Hi Sebastian,

thanks this new release!
just fyi, i think there maybe a typo in the install url? I only
managed to install with 'http' instead of 'https'

about the last feature you asked about, I used kyle's original
imagemagick helpers for a while and found them very useful for stages
in development when thumbnail sizes may vary. my (humble) 2 cents
would be that it makes sense and keeping versions defined only in the
view would keep things DRY...

- Oliver

2005/11/14, Sebastian Kanthak <skanthak@gmail.com>:
B8ed55487e4f2f0feaeb68957dc07b21?d=identicon&s=25 skanthak (Guest)
on 2005-11-15 10:46
(Received via mailing list)
On 11/15/05, Hunter Hillegas <lists@lastonepicked.com> wrote:
> The plus side is that if you add a new size, you don't have to re-input the
> images to get the new sizes.

good point.

> I think that this is a great idea as long as the images are generated only
> if they don't already exist. Having to call ImageMagick for every request
> would kill performance for us on the 5MM/month page view site we are
> developing.

yes, the resized images would be stored in the file_column directory
by default so that they aren't regenerated if the same size is
requested again.

> The thing I like about having it in the model is that I don't have to type
> that geometry string all over... DRY and all that good stuff.

you could put the geometry string in a helper to keep DRY. Another
option would be to keep the definition in the model as a way to define
short-names for geometry strings.

Sebastian
B8ed55487e4f2f0feaeb68957dc07b21?d=identicon&s=25 skanthak (Guest)
on 2005-11-15 10:49
(Received via mailing list)
On 11/15/05, Oliver Barnes <ol1barn3s@gmail.com> wrote:
> just fyi, i think there maybe a typo in the install url? I only
> managed to install with 'http' instead of 'https'

oh, good catch. You need a svn account for the https URL to work... So
here is the correct URL again:

http://opensvn.csie.org/rails_file_column/plugins/...

Installation is as easy as typing

./script/plugin install
http://opensvn.csie.org/rails_file_column/plugins/...

Sebastian
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 james.adam (Guest)
on 2005-11-15 15:27
(Received via mailing list)
On 11/15/05, Sebastian Kanthak <skanthak@gmail.com> wrote:
> How do you make sure as a plugin developer, that your users only use
> stable versions by default?

>From what I can tell, at the moment the plugin script's install
mechanism won't recognise tags or branches at all, if if I'm right
(please someone tell me I'm not?) if you have your repository
organised something like:

  svn://your_svn_url/your_plugin
                                                   |-trunk
                                                   |-branches
                                                   |-tags
                                                         |-0.1.0
                                                         |-0.1.1

... then script/plugin install will pull the whole repository down :S
I believe (from a comment that I posted on the wiki Plugins page) that
some work is being done to support tagged releases, but I'm not sure
when or what we'll see. Fingers crossed...

- james
A7db9ec803b5895ae5f916a74e2db329?d=identicon&s=25 lists (Guest)
on 2005-11-15 17:21
(Received via mailing list)
Personally, I like this last option. Sounds concise.
28668141f2faf4eb9f90fbaab79d220c?d=identicon&s=25 dnstevenson (Guest)
on 2005-11-15 19:51
(Received via mailing list)
Sebastian Kanthak <skanthak@...> writes:

>
> * Right now, I'm using the RMagick library to use the imagemagick
> toolkit. Is it hard to get this working under Windows? Would you
> prefer file_column calling the imagemagick commands directly? I'd like
> to keep the dependency on the RMagick library as it allows for much
> more beautiful code and easier handling of images.
>


I found it a snap to get working under windows as-is.

Dave
213edafaaf6bfb8c6d456aef6bf304ec?d=identicon&s=25 crisdias (Guest)
on 2005-11-16 02:06
(Received via mailing list)
Hi there,

First of all thank you very much for this excellent plugin.

Answering your questions... yes, I run RMagick in Windows and it is a
@#*^#@*&# pain. Right now it just doesn't work, I'm still trying to
figure out which upgrade broke it. But it is not your fault. :-(

Now the request... 8-) One feature I could really use is something
like a before_filter... I made a "poor man's Flickr" for my wedding
pictures (not using file_column) and one of the things I do besides
the resizing is a crop to make the thumbnail square, a la Flickr.
Setting the JPG compression would be another use for this
pre-processing. More fancy ImageMagick processing could also be easily
integrated...

Anyway... just throwing some ideas around. ;-)
B6efa20772f1404cdd68840e95722891?d=identicon&s=25 kheon (Guest)
on 2005-11-16 02:15
(Received via mailing list)
Yeah, I too would definetly like to have a way to crop the photo being
uploaded in an effort to consistently make square thumbnails.

I'd be interested to see how others are doing this currently while using
FileColumn.

Many thanks for FileColumn, it's a huge time saver.

Kyle Heon
kheon@comcast.net
648d60296e65a1278017c0b9f960ec3a?d=identicon&s=25 ol1barn3s (Guest)
on 2005-11-16 17:26
(Received via mailing list)
my guess is that you'd pass a :crop argument just like you can with
:geometry?
I'm assuming (haven't tested it yet) that all imagemagick commands are
accessible this way:
http://www.imagemagick.org/script/command-line-opt...

2005/11/15, Kyle Heon <kheon@comcast.net>:
4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 kyle (Guest)
on 2005-11-16 18:05
(Received via mailing list)
If anyone's curious, they can check out my branch (
http://opensvn.csie.org/rails_file_column/plugins/...
), which includes the following changes:

Changes:
- Removed the "versions" implementation.
- Removed RMagick dependency
- Complete rewrite of Imagemagick functionality.  It uses
IO.popen("mogrify ...").
- Added url_for_file_column "model", "field", :magick =>
command_options.  You can pass command options as a string or
a hash:("-resize 100x100" or :resize => "100x100")
- Added validates_extension_of(*attr_names).  This takes either a
string or an array of extensions.  It validates that the file has one
of the extensions listed.  If it doesn't it tries to convert the file
to the first extension in the list using imagemagick.  If that fails,
then it adds a validation error to the model.

Todo:
- Merge the 0.3.1 updates.
- Add more tests
- Add better support for multi-environment use.  In addition to the
production vs development, multilingual concerns have come up.  I'm
using the multilingual plugin, and I might need to grab a different
version of a file for each locale.  How to make this easy without
increasing overall complexity?
648d60296e65a1278017c0b9f960ec3a?d=identicon&s=25 ol1barn3s (Guest)
on 2005-11-16 18:09
(Received via mailing list)
actually, I think I may have guessed wrong. I just had a look at
magick_file_column.rb, from what I could make out of the code (my
knowledgeg of ruby is limited), it seems only resizing is working
right now...

2005/11/16, Oliver Barnes <ol1barn3s@gmail.com>:
4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 kyle (Guest)
on 2005-11-16 18:30
(Received via mailing list)
0.3.0 only supported the :geometry option, and that should be true of
0.3.1.  Try my branch for generic imagemagick capabilities.  You can
pass any of the command line options, but remember that my branch is
experimental (although I use it in my production sites), and that
imagemagick transformations are handled in the view
(url_for_file_column).
A7db9ec803b5895ae5f916a74e2db329?d=identicon&s=25 lists (Guest)
on 2005-11-16 19:00
(Received via mailing list)
Kyle,

Interesting work.

Does your branch save the results of the transformations so they don't
need
to be run each time they are displayed (i.e. Changing the size only
creates
a new file the first time and subsequent requests pull up that file)?

Hunter
2079c85070a0862b3bb56a8358a33674?d=identicon&s=25 spiceee (Guest)
on 2005-11-16 19:18
(Received via mailing list)
It would be great if you could set prefered image formats along with
resizes - smaller files usually look better in png or gif but with
larger files jpeg has a better quality/size ratio.

I reckon Rmagick has no 'convert' method per se (it converts formats
on-the-fly when a file is saved with a different extension) that's the
main reason I'm going to tamper with the code for file_column a bit..

spe.
4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 kyle (Guest)
on 2005-11-16 20:24
(Received via mailing list)
If you use my branch, assuming png support is compiled into
imagemagick, you can:

url_for_file_column "model", "field", :magick => {:format =>"png",
:resize => "10x10"}

Alternately:

url_for_file_column "model", "field", :magick => "-format png -resize
10x10"
2079c85070a0862b3bb56a8358a33674?d=identicon&s=25 spiceee (Guest)
on 2005-11-16 20:27
(Received via mailing list)
cool, i'll give it a try!

spe.
Bcfc926d36e15709d7e6c70b9791211a?d=identicon&s=25 vamlists (Guest)
on 2005-11-17 11:41
(Received via mailing list)
Sebastian Kanthak wrote:

>Hi there,
>
>I'm happy to announce a new minor release of file_column. It contains
>two small fixes.
>
>
Please correct me if I'm wrong, but a little playing with file_column
tells me that the file name is being stored in the file_column and it
will be retrieved for display from the saved place from the /public
folder. Is there a way I can save the *image itself* in the file column
(that was my original assumption). Which approach is better? Saving
images/files in the database or a regular file system?

TIA,
Vamsee.
B8ed55487e4f2f0feaeb68957dc07b21?d=identicon&s=25 skanthak (Guest)
on 2005-11-17 14:22
(Received via mailing list)
On 11/17/05, Vamsee Kanakala <vamlists@gmx.net> wrote:
> Please correct me if I'm wrong, but a little playing with file_column
> tells me that the file name is being stored in the file_column and it
> will be retrieved for display from the saved place from the /public
> folder. Is there a way I can save the *image itself* in the file column
> (that was my original assumption). Which approach is better? Saving
> images/files in the database or a regular file system?

you're right, the file itself is stored in the filesystem. I believe
this is better (and in this sense, file_column is oppinionated
software), because rails' handling of binary data in the database
isn't very efficient and there is no real reason to put it in the
database anyways. In short, file systems should be pretty good at
storing files... :)

Sebastian
648d60296e65a1278017c0b9f960ec3a?d=identicon&s=25 ol1barn3s (Guest)
on 2005-11-17 14:34
(Received via mailing list)
hi kyle,
I installed your branch and am getting the following error when booting
webrick:

(from locomotive) dependencies.rb:200:in `const_missing':
uninitialized constant BaseUploadedFile (NameError)
        from
./script/../config/../vendor/plugins/kyle/lib/magick_file_column.rb:2

though I can see the BaseUploadedFile class in file_column.rb.

thanks
Oliver

2005/11/16, Kyle Maxwell <kyle@kylemaxwell.com>:
4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 kyle (Guest)
on 2005-11-17 19:16
(Received via mailing list)
Line two or three of file_column.rb loads magick_file_column.rb too
early.  Delete it.  magick_file_column.rb will be loaded later by
init.rb.  Fixed in SVN.  Thanks for the report.
8e44c65ac5b896da534ef2440121c953?d=identicon&s=25 ezra (Guest)
on 2005-11-17 20:10
(Received via mailing list)
On Nov 17, 2005, at 2:40 AM, Vamsee Kanakala wrote:

> Sebastian Kanthak wrote:
>
>> Hi there,
>>
>> I'm happy to announce a new minor release of file_column. It contains
>> two small fixes.
>>

Hey there folks-

	I have a small issue with file_column. In a model that displays home
floor plans I have 2 file_columns. Everything works great for
inputting a new record with 2 photos and saving it and even
displaying it with a show action. Where I run into trouble is when
you want to edit a record that already exists. But I just want to
change some text and have the images left alone. What happens is the
edit form assumes that you want to add new photos and so it displays
the file upload buttons. I already tried to make the edit view just
show the image path text that is stored in the db but when you submit
the edit it all blows up because it is expecting files for those
attributes

	Am I missing something? How do you make it work so the edit page
will let you either upload new photos or leave the old ones alone
without the need to re-upload them every time I just want to edit
some other text fields?


Help?

Thanks-
-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
http://yakimaherald.com
509-577-7732
ezra@yakima-herald.com
B8ed55487e4f2f0feaeb68957dc07b21?d=identicon&s=25 skanthak (Guest)
on 2005-11-19 12:14
(Received via mailing list)
Hi Ezra,

On 11/17/05, Ezra Zygmuntowicz <ezra@yakimaherald.com> wrote:
>         Am I missing something? How do you make it work so the edit page
> will let you either upload new photos or leave the old ones alone
> without the need to re-upload them every time I just want to edit
> some other text fields?

you basically have two options: Either leave the file upload button
there and tell your users to simply not submit anything. This should
keep the old image. Alternatively you can completely leave out an
input element for the image fields. This way, nothing should change
either.

Hope this helps
Sebastian
132a94ca65959bda6c74fae54bff2425?d=identicon&s=25 ezra (Guest)
on 2005-11-19 21:28
(Received via mailing list)
On Nov 19, 2005, at 3:13 AM, Sebastian Kanthak wrote:

> there and tell your users to simply not submit anything. This should
> keep the old image. Alternatively you can completely leave out an
> input element for the image fields. This way, nothing should change
> either.
>
> Hope this helps
> Sebastian


Sebastian-

	OK thanks. I have it working now by just having them leave the file
upload fields alone. That works fine.

Cheers-

-Ezra Zygmuntowicz
WebMaster
Yakima Herald-Republic Newspaper
ezra@yakima-herald.com
509-577-7732
B6efa20772f1404cdd68840e95722891?d=identicon&s=25 kheon (Guest)
on 2005-11-24 01:03
(Received via mailing list)
I'm just starting to learn Ruby so please forgive the bombarding of
questions.

What is the syntax then if I wanted to crop an image say 80x80 with
center
weigthing (belive it's -gravity)? I want to always create an 80x80
square
thumb and then a series of propotional images.

Can all of this be done by setting the model? Right now my model looks
like
this:

file_column :gallery_thumbnail, :magick => {
  :versions => { "thumb" => "80x80" }
}

What should it look like to accomplish what I describe above.

Many thanks for any assistance anyone can provide.

Kyle Heon
kheon@comcast.net
648d60296e65a1278017c0b9f960ec3a?d=identicon&s=25 ol1barn3s (Guest)
on 2005-11-24 13:08
(Received via mailing list)
hi Kyle,
a per earlier on this thread (see Kyle Maxwell's posts about his
branch), FileColumn is moving towards doing the processing in the
view... not positive about the syntax in your case, but I'd try
something like

url_for_file_column "your_model", "gallery", :magick => { :gravity =>
"Center", :crop => "80x80"}

or

url_for_file_column "your_model", "gallery", :magick => { "-gravity
Center -crop 80x80"}

if neither work, I'd look more into how the imagemagick commands
interact

http://www.imagemagick.org/script/command-line-opt...

hope this helps,
Oliver

2005/11/23, Kyle Heon <kheon@comcast.net>:
B8ed55487e4f2f0feaeb68957dc07b21?d=identicon&s=25 skanthak (Guest)
on 2005-11-24 15:09
(Received via mailing list)
Hi Kyle,

On 11/24/05, Kyle Heon <kheon@comcast.net> wrote:
> What is the syntax then if I wanted to crop an image say 80x80 with center
> weigthing (belive it's -gravity)? I want to always create an 80x80 square
> thumb and then a series of propotional images.

unfortunately, the current stable release does not support this, yet.
However, the project's "trunk" allows you to do the following:

<%= url_for_image_column @entry, "image", :size =>"80x80", :crop =>
"1:1" %>

The same thing can be specified in the model as well. Note, however,
that the code is still a bit rough and may have some bugs. Hopefully,
a new release will follow shortly.

Sebastian
D75f4b92f64038bcb02995694c1c9984?d=identicon&s=25 Jeroen janssen (Guest)
on 2005-11-30 17:32
Hi all,

First of all, thanks for the great work on file_column, I'm having some
weird problems though, maybe soemone can help me out.

Uploading works but the uploaded files have the wrong permission (600)
so I can't show them without manually changing the permission.

Another problem is with file_column in combination with magick.

I have a model like this:

class Note < ActiveRecord::Base
file_column :image, :magick => { :versions => { "thumb" => "100x100",
"medium" => "640x480>" }}
end

Now, If I understand correctly, this would result in directories like:
'public/note/image/26/thumb/' and 'public/note/image/26/medium/'
containing the images. However, instead of the 'thumb' and 'medium'
directory I get directories with weird names, like '2489u2' and
'fcfwrb'

Any idea what's going on here?
B8ed55487e4f2f0feaeb68957dc07b21?d=identicon&s=25 skanthak (Guest)
on 2005-12-01 17:58
(Received via mailing list)
Hi Jeroen,

On 11/30/05, Jeroen janssen <jeroen@laika.nl> wrote:
> Uploading works but the uploaded files have the wrong permission (600)
> so I can't show them without manually changing the permission.

the permissions are controlled by the process' umask. I think, if you
set the umask to something more liberal in your environment.rb, you
should be fine.

> 'public/note/image/26/thumb/' and 'public/note/image/26/medium/'
> containing the images. However, instead of the 'thumb' and 'medium'
> directory I get directories with weird names, like '2489u2' and
> 'fcfwrb'
>
> Any idea what's going on here?

It looks like you are using the latest version from trunk? I'm
currently playing around with this stuff, so things might change. If
you want something more stable, look at the releases in the "tags"
directory.

The weird names are based on hashing the options used for the hash.
The idea is that you can specify the options in the view, like this,
too:

<%= url_for_image_column "entry", "image", "50x50" %>

In this case, file_column has no clue what name to use, that's why the
hashes are coming into play.

Having said this, I'm considering changing the default name for
versions declared in the model the way you described. You can always
set a custom name, via the :name option:

   :versions => { :thumb => {:size => "50x50", :name => "foo" } }

Sebastian
7a5ed48939fc288a4c70778140b203f6?d=identicon&s=25 Adam Roth (aroth)
on 2005-12-10 04:58
(Received via mailing list)
I've run into a problem using both file_column (latest SVN release) and
RMagick within the same app. Ever since I installed the plugin my "old
style" non-file_column uploads/image processing code stopped working.
I'd
get the error:

"Uninitialized Constant 'Image'"

which didn't make much sense. The code looked something like this:

## Image Model
require 'RMagick'
def process
  ...
  img = Magick::Image.read( @file.path )  <-- it'd die here
  ...
end

Eventually, when I did a logger.debug Magick, it was more obvious. This
is
the output:

FileColumn::Magick

Is there a namespace collision here? What's going on. I'm in the process
of
converting my site to use file_column, but until thats complete I have
to
use both methods. Is there a way to avoid  having file_column collide
with
RMagick in this way?

Thanks
Adam
3d333b0012928f3dd5a6861cb09ad683?d=identicon&s=25 Kris (Guest)
on 2005-12-12 12:07
I am using file_column 0.3.1 and would say that the biggest problem is
documentation/examples.

RMagick was easy to setup on Windows once the correct download/readme
was found. There is a RMagick installer for Windows which includes
dependancies. You just need to remember to run the postinstall.rb script
afterwards as per readme.

I am having a problem though. Basically I have it all setup, I can
upload and display file which are re-sized as per geometry. But the
versions are not created... no thumbsnails.

My code is:

[code]
file_column :image,
            :magick => { :geometry => "100x100>" },
            :versions => { "thumb" => "50x50>" }
[/code]

Any ideas?
B8ed55487e4f2f0feaeb68957dc07b21?d=identicon&s=25 Sebastian Kanthak (Guest)
on 2005-12-13 00:17
(Received via mailing list)
On 12/12/05, Kris <krisleech@interkonect.com> wrote:
> I am using file_column 0.3.1 and would say that the biggest problem is
> documentation/examples.

I have a fair bit of documentation in the rdocs, but you have to
generate the docs with "rake plugindocs". Of course, more docs are
always better, so patches are very welcome! A complete minimal example
(including model, controller, view, schema...) would be nice, too. So
if anybody writes own be sure to send it to me and I'll include it.

> [code]
> file_column :image,
>             :magick => { :geometry => "100x100>" },
>             :versions => { "thumb" => "50x50>" }
> [/code]
>
> Any ideas?

the syntax for the current svn trunk is ":versions => { :thumb =>
"50x50>" }", perhaps this is the reason?

Sebastian
C9a35b3e1b31a33783e3b4a6b22c3b3c?d=identicon&s=25 Adam Roth (aroth1)
on 2005-12-20 04:43
A new question:

I want to offer my users the ability to add images in two ways:

1) Upload the image
2) Provide a URL to an existing image. The back-end code will download
the picture (using Net::HTTP) and save it to disk where file_column
expectgs it.

...the current catch is that I'd like to be able to use the file_column
helpers for both methods, but I run into a problem. For method #1 I can
do:

@product = Product.new( @params[:product] )
@product.pictures << Picture.new( @params[:picture] )

for method #2, if I can't seem to get around file_column, ie:

@product = Product.new( @params[:product] )
@picture = Picture.new

## Download picture, save to disk code goes here

@picture.filename = @params['picture_url'];  <-- # This will die
@product.picutres << @picture

I can't just "force" a filename. I hope this makes sense.

Any suggestions on how to make this work?

Thanks
4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 Kyle Maxwell (Guest)
on 2005-12-20 07:02
(Received via mailing list)
In the file_column trunk, there's file_compat.rb, which is included
when file_column sees a non-uploaded file, so that the additional
methods of a CGI-uploaded file are present.  Take a look at that code
and patch it into your current installation, or use the current trunk
(stability is uncertain, though there's good test coverage.)

Also, if you are on Ruby 1.8.3, all you have to do to get a remote file
is:

require 'open-uri'
begin
  @picture.filename = open @params['picture_url'];
catch
  #Open will throw all kinds of exceptions: connection errors, 404's,
malformed URLs, etc
end
C9a35b3e1b31a33783e3b4a6b22c3b3c?d=identicon&s=25 Adam Roth (aroth1)
on 2005-12-21 06:40
Kyle,

Thanks for the suggestions. I have been working off the trunk so this
shouldn't be too diffucult to implement. A couple issues though:


When I do:

  @picture.filename = open @params['picture_url'];

I get 'undefined method `original_filename' for
#<File:/tmp/open-uri298.0>'



..but when I do:

  @picture.filename = File.new('/tmp/foo/bar.png');

it runs correctly. Any idea on getting that open-uri download code
working correctly (or am I missing something)?

Thanks again. You've been helpful.

Adam
4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 Kyle Maxwell (Guest)
on 2005-12-21 07:50
(Received via mailing list)
On 12/20/05, adam roth <adam@ridefetish.com> wrote:
> I get 'undefined method `original_filename' for
>
> http://lists.rubyonrails.org/mailman/listinfo/rails
>

irb:> open(@params['picture_url']).class
=> Tempfile

You can't assign a Tempfile to file_column, because then the
extension/mime-type handling is screwed.  A tempfile looks like
/tmp/mytemp34222.0.  So it's not recommended.  You can copy the
tempfile and reopen as a normal File, or if you're feeling hackish,
you can change line 46 of lib/file_column.rb to:

if file.is_a?(File) || file.is_a?(Tempfile)

and brave the consequences.

--
Kyle Maxwell
Chief Technologist
E Factor Media // FN Interactive
kyle@efactormedia.com
1-866-263-3261
This topic is locked and can not be replied to.