Forum: Ruby on Rails Flash Upload and Ruby

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.
heavysixer (Guest)
on 2005-11-15 18:33
(Received via mailing list)
----
Please forgive me if you get this twice, I sent it yesterday but never
saw
it appear on the list.
----

Hi Rubiests,
This is my first posting to the rails group so please forgive me if this
is
a well-covered question (though I did check the wiki and the faqs on the
site).

I am trying to create a Flash-based bulk uploader for my first Ruby
project.
You can see an example of the uploader running in a PHP script here:

http://www.flavoredthunder.com/dev/flash/flashUploader/

This works swimmingly in php but there is no joy in Ruby.

I am using version "0.14.3" of Rails and "1.8.2" of Ruby on a Mac OS X
"10.3
"

The webbrick spits out a very unceremonious error when I try to call my
"admin/flash_create" action:

[14/Nov/2005:23:10:01 PST] "POST /admin/flash_create HTTP/1.1" 500 8175
- -> /admin/flash_create

When doing some research on the problem I found a bug report on the
rails
site:

http://dev.rubyonrails.org/ticket/2277

They suggested installing the flash-fix plugin. I have installed the
flash-fix plugin into my vender/plugin directory but was unsure what to
do
past that.


My very basic method in the admin_controller is:

def flash_create
@params['Filedata']['content _name'] =
File.basename(@params['Filedata']['tmp_name'].original_filename).gsub(/[^a-zA-Z0-9.]/,
'_')
@params['Filedata']['content_type'] =
@params['Filedata']['tmp_name'].content_type.chomp
@params['Filedata']['data'] = @params['Filedata']['tmp_name'].read
@params['Filedata'].delete('tmp_name')
@photo = Photo.new(@params['Filedata'])
@photo.save
end

"Filedata" is the field that Macromedia specifies for their multipart
file
transfers



Any help is greatly appreciated!

thanks,
Mark
ettober (Guest)
on 2005-11-15 18:51
(Received via mailing list)
Hi,
take a look at this:

http://weblog.bubbleshare.com/articles/2005/10/20/...
headaches

Hoipe it helps,

Ettore

Il giorno 15/nov/05, alle ore 17:32, M Daggett ha scritto:
heavysixer (Guest)
on 2005-11-15 19:39
(Received via mailing list)
Yes,
I think he is the one that wrote the plugin. I did incorporate it into
my
rails app but no joy.
heavysixer (Guest)
on 2005-11-16 05:27
(Received via mailing list)
Update!
I was able to get the Flash Ruby synergy all dialed in (sorta).
I updated my blog with the code and details:
http://www.collcoll.com/index.php/2005/11/15/more-...

I am able to get uploads that store the files on the physical drive as
opposed to as a blob in the database.
At first I was a bit confused why this was but then it dawned on me
that I was creating the object in the first method.

def new
   @picture = Picture.new
   ... show the upload page
end

then when flash was called to submit to the page I got an error
because my picture object was nil. I can only assume this is because
the ruby and flash upload happens outside of the scope of ruby's
session object.

When the file was submitted ruby would have no context in which to
view the request. This brings up an interesting question. I originally
inteded on doing some sort of lock/key system whereby my first method
would define a variable and then pass it along to flash so that it
could be embeded into the post (and authenticated by ruby). This would
keep simultanious users from clobbering each other and prevent people
from subverting my upload process.

Here is another problem related to the first. Presently my app
authenticates the user before the URL filter. If the user is not
authenticated then it redirects them to the login. Knowing that I
cannot append anything side the actual post object I guess I am left
with only one option which is to append it to the url string.

Is this wise, does anyone have a better idea?

Thanks,
Mark

On 11/15/05, M Daggett <removed_email_address@domain.invalid> wrote:
> >
> >
> > This is my first posting to the rails group so please forgive me if this
> >
> site:
> > def flash_create
> >     @photo.save
> > Mark
> > removed_email_address@domain.invalid
>
>
>
> --
> --------------------------------------------------------------------
> I am Mark Daggett and I approve this message.
>


--
This topic is locked and can not be replied to.