Forum: Ruby on Rails Upload file with url parameter

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.
2c92287ad4532c0faf7197093a4693a9?d=identicon&s=25 hongseok.com (Guest)
on 2009-05-11 10:29
(Received via mailing list)
I want to upload file using get method.
for example, "http://www.mydomain.com/upload?file=c:\test.exe" upload
my local file to the remote server.
I found one useful link about file uploading here(http://
www.tutorialspoint.com/ruby-on-rails/rails-file-uploading.htm).
Even I've changed some code in order to fit my rails version, it
worked well. But the problem is I have use <form> tag.

I don't know how [view] make UploadedFile and pass it to [controller]
and I tried to find how create UploadedFile. But failed :(

Anyway, how can I upload my local file using above style url?

help me plz, thx
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-05-11 10:54
(Received via mailing list)
On May 11, 7:52 am, "hongseok.com" <hongseok.y...@gmail.com> wrote:
> Anyway, how can I upload my local file using above style url?
>

If you want to just pass the path of the file that won't work - the
file needs to be part of the request body. In theory get requests can
have a request body, but certainly in browser land this isn't common.
it might just work if you set the form's method to get (don't forget
to make the form multipart).
Why is this important ?

Fred
2c92287ad4532c0faf7197093a4693a9?d=identicon&s=25 hongseok.com (Guest)
on 2009-05-11 12:12
(Received via mailing list)
I just want the client(kind a application running automatically) to
upload file to the web server as it wants.

How do I do this?

On 5¿ù11ÀÏ, ¿ÀÈÄ5½Ã53ºÐ, Frederick Cheung <frederick.che...@gmail.com>
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-05-11 12:40
(Received via mailing list)
On May 11, 11:11 am, "hongseok.com" <hongseok.y...@gmail.com> wrote:
> I just want the client(kind a application running automatically) to
> upload file to the web server as it wants.
>
> How do I do this?
>
you'll need to construct an appropriate post request (read up on
multipart post requests) containing the file

Fred
7f79e99165dcbf8256a7acd1dd2f4a29?d=identicon&s=25 PyroHiroshi (Guest)
on 2009-05-12 14:28
(Received via mailing list)
This is exactly what I've been trying to do all day. Not as easy as
you'd think. There are absolutely no examples of this available
anywhere.

It's a wonder that people haven't been trying to do this for a while
'cause it has many different uses, like streaming data directly
through the 80 port when all other ports are blocked.

B

On May 11, 12:39 pm, Frederick Cheung <frederick.che...@gmail.com>
885ac43bca92fc2b1034356f3283e788?d=identicon&s=25 pharrington (Guest)
on 2009-05-12 22:04
(Received via mailing list)
Unless either someone develops a wonderful (i use the term *very*
loosely) exploit or I misunderstand what you're trying to do here,
there is no way to do what you're trying to do. Neither Javascript,
Flash, nor Java (unless the user's insane and sets up their JVM to do
this) can automatically read/serialize/change the value of a field  to
a local file. For very obvious security reasons, the only way to
upload a file with a web browser is for the user to actively select
the file they want, and then to send that in a POST request (GETs will
not work as you cannot serialize the file data).
170e2a48994775e4c298c302e6814f81?d=identicon&s=25 Starr Horne (Guest)
on 2009-05-12 22:21
(Received via mailing list)
The only way to do anything like that would be to have the user install
a client on their computer. For example, you can upload arbitrary files
using adobe air. But otherwise, is verboten.

SH
--
Starr Horne
Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/
Daf51c9cccbb229c8820079c6ba46109?d=identicon&s=25 Peter Vandenberk (Guest)
on 2009-05-13 09:46
(Received via mailing list)
Hi Bennet,

On 12 May 2009, at 13:07, PyroHiroshi wrote:
> This is exactly what I've been trying to do all day. Not as easy as
> you'd think. There are absolutely no examples of this available
> anywhere.

The mechanize gem makes file uploads a no-brainer...

Check out their example script which automates file uploads to Flickr
in 10 or so lines of Ruby code:

     http://github.com/tenderlove/mechanize/blob/a5d73a...

Also check out the mechanize homepage for more examples and API
documentation:

     http://mechanize.rubyforge.org/mechanize/

Mechanize FTW!  ;-)

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