Upload to Database Example

The <dotj:upload> tag can be used to upload files to the application server and store the file in a database. This type of custom logic can be achieved by using an upload listener. This is a class that you write that implements the com.dotj.upload.interfaces.IUploadListener interface.

In this class, you can hook into the lifecycle of the upload processing and customize the logic to fit your own needs. In the example below, we display a list of 10 files that we have stored in our database. You can select a file from the list and upload a new file that will overlay the file in the database.

Be sure to take a look at how this is done. See the sample class called DatabaseUploadListener. It contains the logic to write the file into the database. Specifically, see the persistFileItem method.



Uploaded Files
Row Created Filename ContentType Size (bytes) Action
1 2008/06/04 08:33:27 AM 3.jpg image/jpg 368,050 Overwrite File
2 2006/09/23 07:54:54 AM Blue hills.jpg image/pjpeg 28,521 Overwrite File
3 2007/05/26 07:19:32 AM Winter.jpg image/jpeg 105,542 Overwrite File
4 2007/10/24 09:54:14 AM Sunset.jpg image/pjpeg 71,189 Overwrite File
5 2005/05/27 16:38:29 PM JSF Class Diagram.jpg image/jpeg 44,042 Overwrite File
6 2007/03/23 01:25:33 AM Ravi_Invitation.jpg image/jpeg 151,377 Overwrite File
7 2008/04/17 06:26:33 AM Blue hills.jpg image/jpeg 28,521 Overwrite File
8 2007/12/01 15:23:19 PM Imagen 1.png image/png 488,764 Overwrite File
9 2007/04/23 18:01:09 PM java-disc_small2.gif image/gif 2,274 Overwrite File
10 2008/02/14 07:22:49 AM Blue hills.jpg image/pjpeg 28,521 Overwrite File


 DatabaseUploadListener.java   



          Back to Samples page


home : products : pricing : company : contact us : samples : download : forums : customers

Copyright © 2000-2004 dotJ Software Inc. All rights reserved.