Manage this page

Display

Feedback

Others

Previous questions

You can post questions related to any of the following technologies

Java
J2EE
XML
Dotnet
Programming
SQL
Html
CSS

GQ - Sunday, January 14, 2007 11:04:38 PM

Binary Data and Multipart Encoding

Hi, back again...

Any sample on how aspire would go about saving/retrieving binary data from a database, say for instance mysql blobs?

It might be a stretch, but does aspire have a reader/parser support for multipart data?

GQ - Sunday, February 04, 2007 12:54:32 PM

More on Binary Data and Multipart Encoding

Seems to me aspire doesn't have a prewritten way of handling binary data. The way i understand it, blobs are returned as strings, therefore, you are only limited to text files? Of course, I could be mistaken.

As for multipart encoding, there seems to be some kind of support, but I have no idea how it is used.

Satya - Wednesday, February 14, 2007 9:22:59 AM

Sorry, the notifier is broken and i havent seen your message

Let me look into it. I will let you know. You can email me in the future if you are not able to get answers here quick enough. satya at activeintellect.com

Satya - Thursday, February 15, 2007 10:55:02 PM

I will get you some information on this

for multipart I have used the commons library for file uploading. For binary data in databases, people have written some independent java parts to handle those. If you show me how you intend to use them perhaps I can show you how to write a part to handle them or I can write one for you that is general enough.

Even for the multipart let me know what need are you going to address other than file uploads.

GQ - Tuesday, October 16, 2007 7:52:13 PM

Binary Data for Databases

Consider for instance a catalog of diagrams or photography catalog..

Although i have used the commons library for file uploading, I was wondering how this would be possible to insert data into a blob field while still staying within the aspire framework.

I am currently using the DBHashTableFormHandler1 (to parse form data) and DBRequestExecutor2 (to insert into database)... Will it be necessary to write a custom form handler for this? or is there a simpler way?

annonymous - Tuesday, October 16, 2007 11:08:29 PM

Hi, let me answer tomorrow

Hi, let me answer tomorrow

Satya - Thursday, October 18, 2007 4:24:50 PM

Sorry I haven't had a chance to look at, in the next day or two

Sorry I haven't had a chance to look at, in the next day or two

annonymous - Saturday, October 20, 2007 10:27:53 AM

I had a way to handle file uploads before commons, but I don't think that is flexible

I had a way to handle file uploads before commons, but I don't think that is flexible

Satya - Saturday, October 20, 2007 10:31:06 AM

So, most likely I will have to write a part using commons

Approach for writing the part will be

Derive from AHttpPart a new part called CommonsFileUploadPart

Specify a directory to the CommonsFileUploadPart to drop the files in

Or give variable names to these files so that they can be placed in a jdbc call to the database

Satya - Saturday, October 20, 2007 10:31:21 AM

I will try to write the part this weekend

I will try to write the part this weekend

Satya - Saturday, October 20, 2007 10:33:41 AM

But how are you planning on using it???

Assume you have put a blob in the database. How are you planning on retrieving it and showing it on the browser? Don't you have to stream it? It can be done but is that what you want? will it not work better if you store the files on a file system under a certain directory and place the filename in the database.

Satya - Saturday, October 20, 2007 11:08:50 AM

Here is how we kind of used it before...


* Example properties file
 * ************************
 * request.uploadFileRequest.classname=com.ai.htmlgen.DbPreTranslateArgsMultiRequestExecutor
 * request.uploadFileRequest.request.db=your-db-alias
 * request.uploadFileRequest.request.1=saveFile
 * request.uploadFileRequest.request.2=saveFilenameInDatabase
 * request.uploadFileRequest.redirectUrl=ShowResults
 *
 * request.saveFile.classname=com.indent.actions.portlets.SingleFileUploadPart
 * request.saveFile.fileUploadFormFieldName=filename
 * request.saveFile.targetFilename_WS=aspire:\\mydir\\{user}\\{foldername}}\\abc.txt
 * request.saveFile.resultName=fullfile_name
 *
 * request.saveFilenameInDatabase.classname=com.ai.db.DBRequestExecutor2
 * request.saveFilenameInDatabase.query_type=update
 * request.saveFilenameInDatabase.stmt=(your insert statement)

Satya - Saturday, October 20, 2007 11:21:08 AM

synopsis

This code will save a single uploaded file to a specific directory and saves that file name in the database as a reference.

Satya - Saturday, October 20, 2007 11:23:52 AM

Trouble with this is the access to that file...

THe hope is that you will publish a url to that file for end users to see. If you let the webserver serve that file then access to that file is crude as in either you give all access or no access at all.

If finer control is needed then (i think) you will have to implement some kind of a "file streamer" class or a "databases streamer" class that can take into account access and also setting the file types or content types to the browser.

aspire - Saturday, October 20, 2007 1:14:53 PM

I Can write the parts fairly quickly, but ...

I Can write the parts fairly quickly, I am wondering if you have some bandwidth to test them, especially the "BLOB" functionality. Let me know.

satya - Friday, November 09, 2007 3:56:18 PM

GQ I have done the coding, and you can read it here

How to upload a file to a database and bring it back I have done some basic testing. But I will upload the jar file some time this weekend. But hopefully you have the idea and let me know how you intend to use it.

annonymous - Tuesday, November 27, 2007 11:33:34 AM

See the end result of this uploading effort

See the end result of this uploading effort