Can rails even gracefully upload?

Sorry I really just wanted to have a title to catch attention.

I've had no luck with attachment_fu. It almost works but I've failed
at finding a solution to it's pitfalls.
(http://groups.google.ca/group/rubyonrails-talk/browse_thread/thread/
1101ec5b888b3020/a0418430e0b59f42?lnk=gst&q=brianp#a0418430e0b59f42)
&
(http://groups.google.ca/group/rubyonrails-talk/browse_thread/thread/
c0cf0dc1f54b4058/d845bcc159691698?q=#d845bcc159691698)

And Have now failed trying a method described using paperclip.
(http://www.mfischer.com/2009/02/02/multiple-image-upload-and-crop-
with-rails/)

This is a major problem. It's the only thing currently holding back a
project. I can get a simple uploads to occur. but as soon as i need
multiple related attachments and resizing things fall apart. I do
blame myself being a novice with rails but at the same time, it can't
possibly be this hard.

Every demo, tutorial, article I find is almost a year outdated. And
even most of the demos they give with them fail with rails 2.3.5.

Please prove me wrong and tell me how you manage multiple file uploads.

Hi Brian,

I found myself in the same boat a couple of months ago.
Have you taken a look at paperclip? Its basically the new gen
attachment_fu.
http://jimneath.org/2008/04/17/paperclip-attaching-files-in-rails/

Hope this helps,
it worked for me.

I personally use paperclip, and not attachment-fu, but I also usually end up making an Asset model that is polymorphically associated with my other models. That way, I can keep all of my file handling stuff in one place, as well as keeping the number of attachments flexible.

brianp wrote:

This is a major problem. It's the only thing currently holding back a
project. I can get a simple uploads to occur. but as soon as i need
multiple related attachments and resizing things fall apart. I do
blame myself being a novice with rails but at the same time, it can't
possibly be this hard.

I have used attachment_fu in the past. I've not used it recently though.
I do understand your frustrations even though I have few problems
getting up and running with attachment_fu.

I do believe that most Rails developers now use Paperclip, which I have
not yet had the opportunity to try. I will try it the next time I have a
need.

Part of the frustration with file uploads really have nothing to do with
Rails specifically. Uploading content to a server is in opposition with
security. This fundamentally makes multiple-file uploads somewhat
painful. Direct access to the local file system is specifically limited
in web browsers. JavaScript for example has no access to the local file
system.

There are workarounds, but most of them feel like a hack in themselves
to me. List swfupload, which I believe uses Flash to workaround the file
access issue (since Flash is fundamentally insecure anyway). Other
alternatives I've seen is Java applets to introduce another hackish
workaround for this issue. This can also be a very annoying and
unreliable solution.

Wish I had more to offer in the way of actual help. I do empathize with
your frustrations in this area.

"Convenience is the enemy of security."

We have projects that use SWFUpload for multiple uploads and that includes uploading files going up to hundreds of megabytes, with resizing and thumbnailing. Rails uses attachment_fu or paperclip, it doesn’t matter, they both perform fine. Just make sure u tell attachment_fu models to allow files up to the limit you set and use a rack middleware to preserve the session and/or set the mimetype, because Flash doesn’t preserve it properly. Just google for it. Everything else is just clientside stuff.

Best regards

Peter De Berdt

brianp,

Checkout these railscasts:

http://railscasts.com/episodes/134-paperclip
http://railscasts.com/episodes/182-cropping-images

both used paperclip and they got me up and running in an hr or so. If
you need help e-mail me directly as I only read the group discussion
every day or so.

Brian

Thanks for all the replies everyone.

Just for the record it's not uploading that's the problem as mentioned
by some above it's multiple simultaneous uploads that's the problem.

I think I've come up with a half decent solution for the problem which
I'll gladly post when finished. But I've run into another problem
since. My ImageMagick appears to have run into a new problem. It will
no longer resize images. I've tried re-installing and still receive
this problem:

[paperclip] An error was received while processing:
#<Paperclip::NotIdentifiedByImageMagickError: /var/folders/4s/
4sQnoBr2F2yB6Y37PPp9U++++TI/-Tmp-/1222566365812,87876,0.jpg is not
recognized by the 'identify' command.>

All available searching points in the direction of path problems. I've
tried everything below to no avail (and multiple combination of the
such):
Paperclip.options[:swallow_stderr] = false
Paperclip.options[:command_path] = "/usr/bin"
Paperclip.options[:command_path] = "/opt/local/bin"
Paperclip.options[:command_path] = "/usr/local/ImageMagick/"
Paperclip.options[:image_magick_path] = '/opt/local/bin'

I did notice one post verifying the working processes for convert and
identify in /opt/local/bin. I checked for those process in that folder
and came up empty handed. How can i test these at the command line and
what should i do if they don't work?

I re-installed via Mac Ports.

thanks,
bp