# Readng and writing files on the client side

**URL:** <https://www.ruby-forum.com/t/readng-and-writing-files-on-the-client-side/191196>\
**Category:** Rails\
**Created:** [July 7, 2010, 2:12pm UTC](https://www.ruby-forum.com/t/readng-and-writing-files-on-the-client-side/191196 "2010-07-07T14:12:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [July 7, 2010, 2:12pm UTC](https://www.ruby-forum.com/t/readng-and-writing-files-on-the-client-side/191196/1 "2010-07-07T14:12:49Z")

</div>

I want to use Rails to

(1) Download an executable.  
(2) Interact with a client to select a directory on the client side  
(3) do directory browsing and selecting  
(4) create an xml file of parameters, and write the xml file somewhere  
or pass it to the executable.

Basically, I’d like to use Rails to create a front-end for my user and,  
of course, interact with my Rails server.

* * *

Is this doable or am I better off having my client download a  
stand-alone Ruby application? If a standalone Ruby application is  
better, can someone recommend a GUI that you might suggest?

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [July 7, 2010, 2:31pm UTC](https://www.ruby-forum.com/t/readng-and-writing-files-on-the-client-side/191196/2 "2010-07-07T14:31:09Z")

</div>

On Jul 7, 1:12 pm, Ralph S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I want to use Rails to
> 
> (1) Download an executable.  
> (2) Interact with a client to select a directory on the client side  
> (3) do directory browsing and selecting  
> (4) create an xml file of parameters, and write the xml file somewhere  
> or pass it to the executable.

A pure html/javascript web app has no access to the user’s file  
system (beyond the ability for a user to upload a file of their  
choosing)

Fred

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [July 7, 2010, 3:16pm UTC](https://www.ruby-forum.com/t/readng-and-writing-files-on-the-client-side/191196/3 "2010-07-07T15:16:09Z")

</div>

Frederick C. wrote:

> A pure html/javascript web app has no access to the user’s file  
> system (beyond the ability for a user to upload a file of their  
> choosing)
> 
> Fred

I know this is off topic … but …

I have a C++ Windows command-lnie executable and I want to slap a nice  
front-end on it.

So … if … “A pure html/javascript web app has no access to the  
user’s file  
system” is there something impure that is commonly available?

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [July 7, 2010, 3:54pm UTC](https://www.ruby-forum.com/t/readng-and-writing-files-on-the-client-side/191196/4 "2010-07-07T15:54:29Z")

</div>

Ralph S. wrote:

> I want to use Rails to
> 
> (1) Download an executable.

This part is trivial.

> (2) Interact with a client to select a directory on the client side

This happens automatically depending on what web browser the client  
uses.

> (3) do directory browsing and selecting

Thank goodness this is not possible through standard web technologies.

> (4) create an xml file of parameters, and write the xml file somewhere  
> or pass it to the executable.

Much effort has been put into web browser security to prevent this exact  
process.

That is unless you crack open the shell of security & privacy with  
something like ActiveX or Adobe Flash. This is also why both of those  
have been a “secret weapon” of malicious hackers for years.

> Basically, I’d like to use Rails to create a front-end for my user and,  
> of course, interact with my Rails server.  
>   
> Is this doable or am I better off having my client download a  
> stand-alone Ruby application? If a standalone Ruby application is  
> better, can someone recommend a GUI that you might suggest?

This is rather difficult to answer without knowing what that executable  
program actually needs to do. How complicated will the GUI need to be?  
What are the security & privacy concerns associated with what you’re  
trying to accomplish?

I for one would be extremely reluctant to install your application on my  
system (I wouldn’t have any way to do so anyway given I don’t run  
Windows).

If your site is intended to be used by known clients, that already trust  
you, then there are certainly some options. If your site is even  
remotely public, and you expect clients to “just trust you,” then your  
approach is not plausible. You cannot expect, or force, people to trust  
you. Thankfully trust is in control of the client (unless, of course, if  
the client’s system security has been compromised).

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [July 7, 2010, 4:24pm UTC](https://www.ruby-forum.com/t/readng-and-writing-files-on-the-client-side/191196/5 "2010-07-07T16:24:33Z")

</div>

Robert W. wrote:

> This is rather difficult to answer without knowing what that executable  
> program actually needs to do. How complicated will the GUI need to be?  
> What are the security & privacy concerns associated with what you’re  
> trying to accomplish?

It’s a backup application.

The client selects the files he/she wants to back up and we do our magic  
… not on the server but on the client.

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [July 7, 2010, 4:36pm UTC](https://www.ruby-forum.com/t/readng-and-writing-files-on-the-client-side/191196/6 "2010-07-07T16:36:57Z")

</div>

I agree with most of what Robert said; just wanted to amplify a few  
points.

Robert W. wrote:

> Ralph S. wrote:
> 
> > I want to use Rails to
> > 
> > (1) Download an executable.
> 
> This part is trivial.
> 
> > (2) Interact with a client to select a directory on the client side
> 
> This happens automatically depending on what web browser the client  
> uses.
> 
> > (3) do directory browsing and selecting
> 
> Thank goodness this is not possible through standard web technologies.

Sure it is, with a file input field.

> > (4) create an xml file of parameters, and write the xml file somewhere  
> > or pass it to the executable.
> 
> Much effort has been put into web browser security to prevent this exact  
> process.

Except that you _can_ download a file that you expect the user to open  
in your application. You _may_ even be able to write a browser plugin  
to make the file open in the browser (as Adobe has done with its PDF and  
– yes – Flash plugins).

[…]

> > Is this doable or am I better off having my client download a  
> > stand-alone Ruby application?

It’s hard to tell, at least for me.

> > If a standalone Ruby application is  
> > better, can someone recommend a GUI that you might suggest?  
> > […]

You might like to look at Monkeybars or Limelight.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
