• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Byte[] to File without saving on disk

 
Juan Manuel Diaz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi fellows!!, how are you?, i have been developing an applet to digitally sign PDF files, the applet gets those files from a php page, sign the files and last send each signed file to another php page for saving them in a data base. The problem is in the uploadSignedFile method, this method sends the signed file, receives one parameter, a byte[] with the signed bytes and it must to convert it into a File for send it across the HTTP post protocol. Everything works fine, but when I create the FileOutputStream, a new file appears in my desktop (only in IE7, not with Firefox, I think that is a permissions difference) . I dont want new files on the client disk and they too!, How can I do to manage the File only in memory without saving them in the client disk?

Best Regards,
Juan M. Diaz
 
Rob Spoor
Sheriff
Pie
Posts: 20545
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you create a FileOutputStream it will always create a file on disk if it doesn't exist yet. That's simply what it does. If you want to avoid this you should ask yourself if you really need File, and cannot send the byte[] directly, or send from an InputStream instead. If that's possible you can use a ByteArrayInputStream around the byte[].
 
Juan Manuel Diaz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!, thanks for the quickly answer... I really need File, because the implementation of HTTP Post needs File... If i send the byte[] directly, the php page that receives the files dont work. Is any chance to use File in memory?

Regards,
JM Diaz
 
Juan Manuel Diaz
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved. I found a method that spec an InputStream as argument. I use ByteArrayInputStream.

Thanks,
JM Diaz
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic