[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ruby (rails) and rjb: java File I/O

raf

3/5/2007 10:12:00 PM

I am trying to do file i/o with rails and rjb and can't figure out a
way to make this work.

Here's what I am trying to do:
- a user uploads an image to the server via a standard html form:
<%= file_field("blog", "attach") %>
- this returns a ruby File object to the controller in
params[:blog][:attach]
- then I need to convert this into a Java InputStream object in order
to use it as an argument to another Java method.

I have tried to accomplish this many ways by using the obvious
approach ... all without success.
For example,
- read the contents of the file into a ruby string, then try to create
a java ByteArrayInputStream directly from this.
- read the contents of the file into a ruby string, create a java
String from this and then try to create a java ByteArrayInputStream
from the java String
- and many other permutations
I fear I am missing something very simple here...

Has anyone accomplished something like this? If so I would appreciate
seeing a sample of actual working code.

Thanks,
Martin