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

R

raf

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top