FTP Save As box

0 views
Skip to first unread message

Chris Booth

unread,
Jul 9, 2008, 9:51:04 AM7/9/08
to Orlando Ruby Users Group Discussion
Hey folks.

I've completely run out of ideas of what to google here.

I'm using Net::FTP to allow users to download files from my server. I
have a form on my page with a select box list of available files to
download and a "Save" submit button. I've hard-coded the save-to path
in my code for testing and that seems to be working fine.

However, now I want to pop up a dialog when the user clicks the "Save"
button to allow them to select the destination path and file name. I
have found absolutely nothing on the web so far to give me a clue how
to do this in RoR.

So I'm wondering if anyone can point me in the right direction or if
this is even the way to do this?

Thanks,

Chris

Billy Watson

unread,
Jul 9, 2008, 11:15:34 AM7/9/08
to orug-di...@googlegroups.com
Couldn't you use ruby to write operating system commands like to list directories and have the user pick one? Obviously, it'd all be custom, but once you're done you'd have a nifty plugin.

Ex:  
system('ls -l')

--
William Watson
Information Systems Developer
(904) 705-7056 PCS
williamrwatson.tumblr.com

Anthony Eden

unread,
Jul 9, 2008, 6:33:02 PM7/9/08
to orug-di...@googlegroups.com
I believe the OP wants this to run from the browser, in which case
you'd have to have a way to access the local system using either a
browser plug in, ActiveX control, Java applet, etc.

Sincerely,
Anthony Eden

Billy Watson

unread,
Jul 9, 2008, 7:15:49 PM7/9/08
to orug-di...@googlegroups.com
Oh, I see. The directories need to be local directories for the user and not local directories for the server. Yeah, that's a problem. 

You'll have to do it how Anthony said or open the file in a new window using Javascript. That way the browser will pick it up and automatically open a download box for the user.

Sorry about the confusion. Was at work and didn't read it well enough. :)


-- 
William Watson
Information Systems Developer
(904) 705-7056 PCS
williamrwatson.tumblr.com

Michael Blake

unread,
Jul 9, 2008, 7:33:12 PM7/9/08
to orug-di...@googlegroups.com
You can use button_to in Rails to link to a file on your server and
that will automatically give you the Save As dialog box. However
that only works for a single file. To handle multiple files, look at
how Google does it in Gmail with the "Download all attachments",
that gives you multiple files in a .zip . So you'll need code on
your server to zip up files the user has selected.

Chris Booth

unread,
Jul 10, 2008, 9:17:15 AM7/10/08
to Orlando Ruby Users Group Discussion
Thanks for the replies.

Anthony, you're correct. We're trying to allow the user to select a
directory on their local machine (not the server) to download the file
to. Essentially, I'm trying to replicate the "right-click, save file,
get the save to box" process only with FTP. And we only need to
download one file at a time, so multiple file download isn't an issue
(yet, anyway).

If I link to a file using button_to, it will be an HTTP transfer
instead of FTP correct? Or if I open the file in a new window using
Javascript, that will be HTTP xfer as well, right? Which I guess begs
the question, is there anything inherently better about FTP file
transfer over HTTP file transfer? We're dealing with files here that
range in size from a couple KB to 1GB (give or take). Are there
issues with large file xfers over HTTP? Are there significant speed
differences? Maybe I should take the easy road and just do HTTP
transfer to get the built-in browser save-to functionality? Any
thoughts?

Thanks,

Chris
Reply all
Reply to author
Forward
0 new messages