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

Discussion in 'Ruby' started by raf, Mar 5, 2007.

  1. raf

    raf Guest

    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
    raf, Mar 5, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Adam Keys

    rjb and Java 1.5

    Adam Keys, Mar 10, 2006, in forum: Ruby
    Replies:
    0
    Views:
    85
    Adam Keys
    Mar 10, 2006
  2. Wes Gamble
    Replies:
    1
    Views:
    127
    MenTaLguY
    Mar 7, 2007
  3. Andre Ferreira

    Ruby and EJavaBeans with RJB

    Andre Ferreira, May 9, 2007, in forum: Ruby
    Replies:
    0
    Views:
    93
    Andre Ferreira
    May 9, 2007
  4. Shashank Agarwal
    Replies:
    2
    Views:
    138
    Tiago Macedo
    Jun 30, 2008
  5. Anukul Singhal
    Replies:
    0
    Views:
    148
    Anukul Singhal
    Mar 9, 2010
Loading...

Share This Page