com.gentics.api.lib.upload
Interface FileUploadProvider


public interface FileUploadProvider

The Interface FileUploadProvider defines the API for retrieving files that were uploaded via a HTTP POST. Gentics portlets and plugins may obtain an instance of a FileUploadProvider via GenticsPortlet.getFileUploadProvider()or GenticsPlugin.getFileUploadProvider()respectively.


Method Summary
 FileInformation getFileInformation(java.lang.String fieldName)
          Get the file information of an uploaded file by field name.
The retrieved value will depend on the client's operating system: Windows delivers Full Path, *NX delivers only FileName
 long getMaxFilesize()
          Get the maximum allowed filesize
 java.lang.String getParameter(java.lang.String fieldName)
          Get the value of a non-file parameter (similar to PortletRequest.getParameter(java.lang.String))
 java.util.Map getParameterMap()
          Get all non-file parameters as map (similar to PortletRequest.getParameterMap())
 java.util.Enumeration getParameterNames()
          Get all parameter names of non-file parameters (similar to PortletRequest.getParameterNames())
 java.lang.String[] getParameterValues(java.lang.String fieldName)
          Get values of a non-file parameter (similar to PortletRequest.getParameterValues(java.lang.String))
 java.lang.String getRepositoryPath()
          Returns the current repository path used for uploaded files.
 int getSizeThreshold()
          Returns the current max limit for files hold in memory.
 java.io.InputStream getStream(java.lang.String fieldName)
          Get an input stream for retrieving the file content by field name
 void invalidate()
          Called (by the portal) when the provided information is no longer needed.
 java.io.File save(java.lang.String fieldName, java.lang.String path)
          TODO: difference to saveAs(String, String)
 java.io.File saveAs(java.lang.String fieldName, java.lang.String filePath)
          Directly store the specified uploaded file into the filepath and return the representing file object.
 void setMaxFilesize(long maxFilesize)
          Sets a max limit for a fileupload
 void setRepositoryPath(java.lang.String repositoryPath)
          Sets the repository path for the uploaded file
 void setSizeThreshold(int sizeThreshold)
          Sets a max limit for the size threshold.
 

Method Detail

setMaxFilesize

void setMaxFilesize(long maxFilesize)
Sets a max limit for a fileupload

Parameters:
maxFilesize - set max file size in bytes

setSizeThreshold

void setSizeThreshold(int sizeThreshold)
Sets a max limit for the size threshold.

Parameters:
sizeThreshold - in bytes

getSizeThreshold

int getSizeThreshold()
Returns the current max limit for files hold in memory.

Returns:
the max limit for files hold in memory.

setRepositoryPath

void setRepositoryPath(java.lang.String repositoryPath)
Sets the repository path for the uploaded file

Parameters:
repositoryPath - absolute Path

getRepositoryPath

java.lang.String getRepositoryPath()
Returns the current repository path used for uploaded files.

Returns:
the current repository path used for uploaded files.

getStream

java.io.InputStream getStream(java.lang.String fieldName)
                              throws java.io.FileNotFoundException
Get an input stream for retrieving the file content by field name

Parameters:
fieldName - name of the upload field
Returns:
input stream or null when the upload field was left empty
Throws:
java.io.FileNotFoundException - when the file was not found (field not present in form)

getFileInformation

FileInformation getFileInformation(java.lang.String fieldName)
                                   throws java.io.FileNotFoundException,
                                          org.apache.commons.fileupload.FileUploadException
Get the file information of an uploaded file by field name.
The retrieved value will depend on the client's operating system: Windows delivers Full Path, *NX delivers only FileName

Parameters:
fieldName - name of the upload field
Returns:
FileInformation object or null if the upload field was left empty
Throws:
java.io.FileNotFoundException - when the file was not found (field not present in form)
org.apache.commons.fileupload.FileUploadException
org.apache.commons.fileupload.FileUploadException - when the upload fails

getParameter

java.lang.String getParameter(java.lang.String fieldName)
Get the value of a non-file parameter (similar to PortletRequest.getParameter(java.lang.String))

Parameters:
fieldName - name of the field
Returns:
value of the "normal" form field

getParameterValues

java.lang.String[] getParameterValues(java.lang.String fieldName)
Get values of a non-file parameter (similar to PortletRequest.getParameterValues(java.lang.String))

Parameters:
fieldName - name of the field
Returns:
String array of values

getParameterMap

java.util.Map getParameterMap()
Get all non-file parameters as map (similar to PortletRequest.getParameterMap())

Returns:
parameter map

getParameterNames

java.util.Enumeration getParameterNames()
Get all parameter names of non-file parameters (similar to PortletRequest.getParameterNames())

Returns:
enumeration of parameter names

save

java.io.File save(java.lang.String fieldName,
                  java.lang.String path)
                  throws java.lang.Exception
TODO: difference to saveAs(String, String)

Parameters:
fieldName - fieldname of the uploaded file
path - file path to save the file
Returns:
file object if created or null
Throws:
java.lang.Exception - an Execption ???

saveAs

java.io.File saveAs(java.lang.String fieldName,
                    java.lang.String filePath)
                    throws java.lang.Exception
Directly store the specified uploaded file into the filepath and return the representing file object. filePath is the complete path and filename.

Parameters:
fieldName - ENTER FULL fieldName (e.g.: p.file)
filePath - ENTER ONLY PATH NAME (NO NEED TO ADD ANY '/' OR '\'
Returns:
file object if created or null
Throws:
java.lang.Exception - an Execption ???

invalidate

void invalidate()
Called (by the portal) when the provided information is no longer needed. (when instance is given back to the portal). this removes all information prepared in #setActionRequest(ActionRequest) by calling delete() for all FileItems


getMaxFilesize

long getMaxFilesize()
Get the maximum allowed filesize

Returns:
maximum allowed filesize


Copyright © 2013 Gentics Software GmbH. All Rights Reserved.