Forum: Ruby on Rails Multiple file upload w/Rails 2.x

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.
Fcf6328e679123eb81f8576eae5e8f74?d=identicon&s=25 wejrowski@gmail.com (Guest)
on 2009-05-15 00:20
(Received via mailing list)
Been searching forever. I need to create a multiple file uploader. I
can do single files, but I want to do multiple. I think flash is my
only option. But my problem is I can't get flash to communicate. May
be something with the auth code, I've tried passing the auth code to
Flash and back to Rails in POST but no luck.

Anyone know a good resource? I want to be able to understand what's
going on, and preferably build it myself (I've built it with AS3/PHP
before).
41cc2c53544016a86472343ab3fdc0ff?d=identicon&s=25 Simon Macneall (Guest)
on 2009-05-15 00:33
(Received via mailing list)
we are using swfupload, which works pretty well. It allows you to show
progress of each upload etc. We switched to this because the customer
wanted a multi-select file dialog.

before that, we had rolled our own js solution, which allowed the user
to pick one file at a time, but upload them all at once. basically, a
normal file upload, with a 'add another file' link which dynamically
built another file upload element in the dom. was pretty easy to set up
actually.

Cheers
Simon
Fcf6328e679123eb81f8576eae5e8f74?d=identicon&s=25 wejrowski@gmail.com (Guest)
on 2009-05-15 01:44
(Received via mailing list)
That looks like a start. But what about integrating it with Rails?
That's my problem, I can't get Flash to talk to rails. I don't see any
documentation for it on their site.
Bcf90c1670e31d618edfa4be80bf17b4?d=identicon&s=25 Everton J. Carpes (Guest)
on 2009-05-15 02:03
(Received via mailing list)
There is no Rails solution for this, cause upload is normally controlled
by
the server.. If you (like me) don't want or can't use Flash based
solutions,
you should work using modules on the server and creating client side
solutions using Javascript.

At this moment i'm working in something like that, the solution is
really
not trivial, but not very complicated.

Here you can see an example (about progress bar):

http://railsillustrated.com/screencast-file-upload...

One side effect for this approach is that this turn much more
complicated to
test the process, but between choose a dependency at client side and a
dependency at server/development side, i really prefer the second one.


On Thu, May 14, 2009 at 8:43 PM, wejrowski@gmail.com
<wejrowski@gmail.com>wrote:

>
> That looks like a start. But what about integrating it with Rails?
> That's my problem, I can't get Flash to talk to rails. I don't see any
> documentation for it on their site.
> >
>


--
Everton J. Carpes
Mobile: +55 53 9129.4593
MSN:    maskejc@gmail.com
UIN:    343716195
Jabber: everton.carpes@jabber.org

"If art interprets our dreams, the computer executes them in the guise
of
programs!" - Alan J. Perlis
41cc2c53544016a86472343ab3fdc0ff?d=identicon&s=25 Simon Macneall (Guest)
on 2009-05-15 02:20
(Received via mailing list)
It does a normal post, just like any other js that is generated from
rails, so it's just a matter of reading the params on the other end.
Bcf90c1670e31d618edfa4be80bf17b4?d=identicon&s=25 Everton J. Carpes (Guest)
on 2009-05-15 02:27
(Received via mailing list)
I can't understand if you are telling that for me, but i will reply
anyway... if your reply was for the Flash solution, sorry (just ignore).

It does a normal post, just like any other js that is generated from
rails,
> so it's just a matter of reading the params on the other end.


Yes, is just that, except by the fact that "the other end" should be
working
in a very specific environment... to test this kind of thing, you should
be
using in development environment  the same environment of production
(with
the same server and module plus traffic band limiter to simulate the
thing)
and at test environment a lot of complex mocks to simulate the same
environment... this is not so trivial like it would be.


--
Everton J. Carpes
Mobile: +55 53 9129.4593
MSN:    maskejc@gmail.com
UIN:    343716195
Jabber: everton.carpes@jabber.org

"If art interprets our dreams, the computer executes them in the guise
of
programs!" - Alan J. Perlis
Fcf6328e679123eb81f8576eae5e8f74?d=identicon&s=25 wejrowski@gmail.com (Guest)
on 2009-05-15 02:58
(Received via mailing list)
I actually have my own uploader class for Flash, which uploads
multiple files one after the other. The only thing I need to know is
how to get Rails to retrieve that file. Any simple solutions/tutorials?
885ac43bca92fc2b1034356f3283e788?d=identicon&s=25 pharrington (Guest)
on 2009-05-15 03:43
(Received via mailing list)
params[:file_upload_field] will just be a slightly enhanced File
object; call it's original_filename method to get the path it was
uploaded to on the server and you can use your everyday FileUtils,
File, and IO methods on it to do as you please.
885ac43bca92fc2b1034356f3283e788?d=identicon&s=25 pharrington (Guest)
on 2009-05-15 03:45
(Received via mailing list)
sorry, local_path will return the tempfile's path on the server;
original_filename will return... the basename of the original file
(even accomodating for IE's wonkiness)
Fcf6328e679123eb81f8576eae5e8f74?d=identicon&s=25 wejrowski@gmail.com (Guest)
on 2009-05-15 03:52
(Received via mailing list)
I can mess with it again... but if I use Flash, is there anything out
of the ordinary I need to do (eg with the authentication in Rails
2.x)? I used the same Flash script that worked to send to PHP to Ruby
and I couldn't get Ruby to do anything with the files (using Rails
script that worked with static html uploads).
885ac43bca92fc2b1034356f3283e788?d=identicon&s=25 pharrington (Guest)
on 2009-05-15 04:09
(Received via mailing list)
As to the CSRF part, you'll need to pass the authenticity_token into
Flash somehow (my Flash is pretty terrible, so I wouldn't really know
how to do that; i guess a start would be knowing #
{form_authenticity_token} is the String containing the authtoken).
Otherwise you can call

skip_before_filter :verity_authenticity_token, :only =>
'upload_action'

To skip the authenticity token check, if you feel your app has strong
enough security without it.
This topic is locked and can not be replied to.