1. You will be using commons file upload plugin or part
2. You will need to add a url rewrite filter that comes with aspire to convert extra path to url arguments
3. You will "singlefileuploadpart" to parse the multipart upload
4. You will use a PSExecutor2 part to save it as a blob in the database
5. You can BlobTransform to write it back to the browser
<filter>
<filter-name>DisplayParamFilter</filter-name>
<display-name>DisplayParamFilter</display-name>
<description>DisplayParamFilter</description>
<filter-class>com.ai.servlets.paramfilters.DisplayParamFilter</filter-class>
<init-param>
<param-name>parm1</param-name>
<param-value>parm1value</param-value>
<description>description</description>
</init-param>
</filter>
<filter>
<filter-name>UpdateParamFilter</filter-name>
<display-name>UpdateParamFilter</display-name>
<description>UpdateParamFilter</description>
<filter-class>com.ai.servlets.paramfilters.UpdateParamFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>DisplayParamFilter</filter-name>
<url-pattern>/display/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>UpdateParamFilter</filter-name>
<url-pattern>/update/*</url-pattern>
</filter-mapping>
<form action="/webapp/update/uploadRequestName"
enctype="multipart/form-data" method="post">
<p>
Type some text (if you like):<br>
<input type="text" name="textline" size="30">
</p>
<p>
Please specify a file, or a set of files:<br>
<input type="file" name="datafile" size="40">
</p>
<div>
<input type="submit" value="Send">
</div>
</form>
Notice the "uploadRequestName" how it is specified. This is possible if you configure the above filters only.
##set up the pipeline
request.uploadRequestName.classname=com.ai.db.DBPreTranslateArgsMultiRequestExecutor
request.uploadRequestName.request.1=parseUsingCommons
request.uploadRequestName.request.2=ConvertFileItemToBlob
request.uploadRequestName.request.3=SaveBlob
##redirect after success
request.uploadRequestName.redirectURL=/webapp/somepage?a=b
##parsing: fileitem will be checked in as your form field name
request.parseUsingCommons.classname=com.ai.parts.SingleFileUPloadCommonsPart
#the following line is not used. The fileitem is checked
#under the name of the form field
#request.parseUsingCommons.fileuploadFormFieldName=datafile
##convert to blob
request.convertfileitemtoblob.classname=com.ai.parts.FileItemToBlobPart
request.convertfileitemtoblob.fileItemKey=datafile
request.convertfileitemtoblob.fileStreamKey=datafileStream
##save blob
request.saveblob.classname=com.ai.db.ps.PSExecutor2
request.saveblob.db=your-db
request.saveblob.stmt=\
insert into table1 (blobcolumn, filename,filesize,someid)
values (?,?,?,?)
request.saveblob.paramlist=\
datafileStream,blob|datafileStream_filename|datafileStream_length,int|someid,int
downloadfileURL=no-template
downloadfileURL.transformtype=jsp
downloadfile.transform.classname=com.ai.htmlgen.streamers.BlobTransform
downloadfile.transform.blobRequestName=readBlob
downloadfile.transform.blobKey=blobColumnName
downloadfile.transform.filenameKey=filenameColumnName
downloadfile.transform.fileLengthKey=fileLengthKeyColumnName
request.readBlob.classname=com.ai.db.DBRequestExecutor2
request.readBlob.db=somedb
request.readBlob.stmt=slect * from some table where id = {someid}
I will put this up tomorrow. I have the details somewhere else.
Build 24
This code is in alpha state. email me when you run into issues.
aspire - Wednesday, November 14, 2007 10:42:44 AM
You will need the following global definitions for file upload to work
#############################################
#Global file definitions
#############################################
aspire.global-defaults.fileupload.MaxMemorySizeInKb=1000
aspire.global-defaults.fileupload.maxRequestSizeInMb=10
aspire.global-defaults.fileupload.tempDirectory=c:\\work
aspire - Wednesday, November 14, 2007 10:43:31 AM
A sample file upload properties
#############################################
#Test File Upload
#############################################
request.testFileUpload.classname=com.ai.data.PreTranslateArgsMultiRequestExecutor
request.testFileUpload.request.1=parsemultipart
request.testFileUpload.request=FULCopyFile
#############################################
#Global file definitions
#############################################
aspire.global-defaults.fileupload.MaxMemorySizeInKb=1000
aspire.global-defaults.fileupload.maxRequestSizeInMb=10
aspire.global-defaults.fileupload.tempDirectory=c:\\work
#############################################
#Copy file
#############################################
request.FULCopyFile.classname=com.ai.parts.FULCopyFilePart
request.FULCopyFile.targetDirectory=c:\\work\\testdir\\{profile_user}
request.FULCopyFile.filename=test.dat
request.FULCopyFile.fileuploadFormFieldName=datafile
request.parsemultipart.classname=com.ai.parts.SingleFileUPloadCommonsPart
#The following is read but it is not used
#request.testFileUpload.fileUploadFormFieldName=datafile