• Post Reply Bookmark Topic Watch Topic
  • New Topic

save this byte array to jpg file ?

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I upload a jpg file from jsp to server. The server could receive the byte array. like

file is saved, but it is zero size.


My goal is to save this byte array to jpg file.

Any suggestion ?

Thanks.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to ask the obvious: the byte array is not zero-sized on the server?
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
Just to ask the obvious: the byte array is not zero-sized on the server?

No, the byte array is NOT zero size or null. like


Thanks.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the most common source of trouble here is failing to close the stream, but it looks like you're doing that. I think the main two possibilities here are (a) you aren't actually writing the file at all, because this code isn't being called (but somethign else previously wrote a 0-length file), or (b) you are writing the file correctly, but some other code is running shortly afterwards which is overwriting the file with a 0-lenght file. I recommend adding some disagnostic ourput immediately after writing the file:

The output (or lack of it) should help you identify what is or is not happening in your program.
[ August 05, 2007: Message edited by: Jim Yingst ]
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My theory is that you happen to have a zero-length file in the directory where you expect the file to be written, but in reality you don't know what the server's current working directory is, and the file is being written successfully in some directory that you didn't expect.

But Jim's code should tell you if that's the case.
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jim Yingst:
(b) you are writing the file correctly, but some other code is running shortly afterwards which is overwriting the file with a 0-lenght file.
[ August 05, 2007: Message edited by: Jim Yingst ]

It is this case.

Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!