Robert,
I can see one obvious mistake... but may be I'm wrong.
> byte buf[] = new byte[2048];
> int s, tl = 0;
> while ((s = bis.read(buf, 0, 2048)) > 0) {
> tl += s;
> }
>
> myDAO.setLOBField(buf);
> myDAO.save();
>
Your byte array buf[] is always a 2KB in size irrespective of the file
size! I expect any 1 page Word Doc to be way larger than 2 KB. You
should do something like -
File binaryFile = new File(filename);
FileInputStream fistream = new FileInputStream(binaryFile);
byte[] filedata = new byte[(int) binaryFile.length()];
fistream.read(filedata);
fistream.close();
imgdb.setData(filedata);
It atleast works for me! I tried it for around 5MB image file. I guess
the problem is with your code (no offense - we all make mistakes ;-) and
not Torque.
> And to load it I do the following:
>
> byte buf2[] = myDAO2.getFitxer();
> OutputStream out = new FileOutputStream("myFile");
> out.write(buf2);
> out.close();
The code for loading seems to be fine because Torque (actually JDBC I
guess) creates the array for you.
>
> .... And all I get is a bunch of junk when I open it in
> Word.
>
Expected!
Hope it helps.
~Sarav
P.S: Ben, a reply to your question will be a long mail. Don't have time
yet. Will do when I get time.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]