File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPG�s from db and then deleting the files

 
Jeppe Sommer
Ranch Hand
Posts: 270
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have made a photo gallery.

1) First I read in the jpg�s as Blobs. For each Blob value I convert it to a BinaryStream which I write to a file ( FileOutputStream ).

2) Then I preview the jpg in a browser with the HTML tag <img src="PATH_TO_FILE.jpg">. I just make a reference to the directory and file...

That works fine!

The problem is that I don�t know how to delete all those files that I write
to the directory after reading the blob from the database.

Do I have to make a batch job to delete all the files or is it possible to show the jpg�s in the browser without writing the blob to a file first?
[ November 18, 2004: Message edited by: Jeppe ]
 
Ben Wood
Ranch Hand
Posts: 342
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can send an image to a browser without writing a file using a servlet. The response type of the servlet would be the image mime type (e.g. image/png for png files) and instead of writing the image data to a file output stream you would send it to the servlet's output stream.

in the servlet it might look something like this...



If you call this servlet as the URL for your image then the browser should display it

e.g.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic