• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 697
  • Last Modified:

Struts FormFile

I have a web application that is written in struts. In the application a user can enter info and upload a file.
All of this is then stored in a database.  I have retrieved the uploaded file from the database and have it in
byte[] array.

How do I put this back into the struts FormFile????


Anyone?

Thanks
0
u9707118
Asked:
u9707118
1 Solution
 
bloodredsunCommented:
Somehting like this:

// .. get data into an array named "byteArray"
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(byteArray));
 
// .. get FormFile object
FormFile formFile= (FormFile) ois.readObject();
 
// close the input stream
ois.close();
0
 
u9707118Author Commented:
didn't work, I'm afraid :(
0
 
bloodredsunCommented:
what was the error/exception?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
bloodredsunCommented:
I think so, I think I misunderstood the question. I thought he wanted to deserialize the actionform when he just wanted to know how to put a byte array back in the form....
0
 
u9707118Author Commented:
Sorry, I forgot about this question....

I managed to get around the problem by storing the file in the session and not in the action form.
I did try your code at the time, I remember that the code did execute i.e. it seemingly read the file bytes
into the FormFile without throwing any exceptions, but when I tried to retrieve the file an exception occurred.

I can't remember what exactly the error said...something like corrupt data.
0
 
bloodredsunCommented:
not a problem u907118, you get your points back for answering it yourself :-)
0
 
VenabiliCommented:
Changed recommendation: PAQ- refund
0
 
bloodredsunCommented:
>> Changed recommendation: PAQ- refund
Agreed
0
 
moduloCommented:
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now