>When I submit my 'FileUploadFom.vm', my selected file is 
>not uploaded into my server directory. 
>this directory is still empty.
>In my turbine.properties, I defined the prop. 
>'service.TurbineUploadService.repository=c:\upload'
>I didn't change the class name assigned to the upload service.


If the size of the incoming file is less than size.threshold it is stored in
memory. This may be where your files are. Also unless automatic is set to
true in TurbineResources, ParameterParser wont pull out the multi-part data
for you, you will have to do it with a getRequest() to TurbineUpload.

Below is the section for the Upload Service from a services.xml doc. I
havent commited the xml yet as it isnt complete. It is probably overkill but
may help. Hope the formatting comes out right.



Cameron Riley





-----------------------------------


The Upload Service handles the parsing of multi-part/form-data from POST
Requests, making the multi-part files available from either memory or from a
specified location on the file system. The TurbineResources.properties file
contains the entries; 


# -------------------------------------------------------------------
# 
#  U P L O A D  S E R V I C E
#
# -------------------------------------------------------------------

# Whether the files should be automatically picked up by
# ParameterParser.

services.TurbineUploadService.automatic=false

#
# The directory where files will be temporarily stored.
#
services.TurbineUploadService.repository=.

#
# The maximum size of a request that will be processed.
#
services.TurbineUploadService.size.max=1048576

#
# The maximum size of a request that will have it's elements cached in
# memory by TurbineUploadService class.
#
services.TurbineUploadService.size.threshold=10240



Change the automatic directive to true. With this set to true any
multi-part/form-data requests which Turbine fields, will be parsed and the
appropriate files made available to ParameterParser as FileItem Objects. If
this is set as false, the FileItems will have to be parsed out of RunData
manually with the method getRequest() available from TurbineUpload. 

Set the remaining values to ones approriate for your installation. On Win32
file systems for the repository directive, an entry of the form; 

  f:\\path\\to\\upload\\repository 
 
is most likely necessary. 

Create an HTML form of the type; 


<form enctype="multipart/form-data" method="POST">
<input type="hidden" name="action" value="UploadExample" /> 
<input type="file" name="filename">
<input type="submit" value="upload" />
</form>


The Upload Service manages if the FileItem is stored by in Memory or as in
the Repository specified in TurbineReources.properties. It is also possible
to overide the TurbineResources setting for the repository by using
TurbineUpload.getRequest() to parse the request with a custom repository
directory. The TurbineUpload Object serves as a Facade to the Upload Service
by making available static methods to manage the upload internally in your
application. The FileItems can be accessed in an UploadExample Action class
by; 

public void doPerform(RunData data, Context context) throws Exception
{
   //get the ParameterParser from RunData
   ParameterParser params = data.getParameters();
                                             
   //grab the FileItems available in ParameterParser
   FileItem fi = params.getFileItem("filename");
                                            
   //do work on the FileItem
   //get the file as a File
   //or outputstream etc.

}
                                            
Once a new Instance of the FileItem is created many public methods are
available to work on the Object, whether it is in temp storage as memory or
as a temp file on part of the file system. All the temp storage management
and clean up occurs behind the scenes and is transparent to the application
being based on Turbine. There is no need to manually clean up the FileItems
as the FileItem Object doesnt span Requests ( or RunData instances ) and the
temp files that use the file system are cleaned up in a finalize() method
inherited from Object(). 

The TurbineUpload Object and the FileItem Object give all the functionality
needed to manage this sort of operation or action at the application level.
For more detailed information on the methods available to deal with uploaded
files, view the relevant Javadocs for TurbineUpload, ParameterParser and
FileItem. 






------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to