public class FileUploadPlugin extends XWikiDefaultPlugin
FileItems.| Modifier and Type | Field and Description |
|---|---|
static String |
FILE_LIST_KEY
The context name of the uploaded file list.
|
static String |
PLUGIN_NAME
The name of the plugin; the key that can be used to retrieve this plugin from the context.
|
static String |
UPLOAD_MAXSIZE_PARAMETER
The name of the parameter that can be set in the global XWiki preferences to override the default maximum file
size.
|
static String |
UPLOAD_SIZETHRESHOLD_PARAMETER
The name of the parameter that can be set in the global XWiki preferences to override the default size threshold
for on-disk storage.
|
| Constructor and Description |
|---|
FileUploadPlugin(String name,
String className,
XWikiContext context) |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanFileList(XWikiContext context)
Deletes all temporary files of the upload.
|
void |
endRendering(XWikiContext context)
Hook method, called after the 1.0 rendering engine finished processing a wiki document.
|
org.apache.commons.fileupload.FileItem |
getFile(String formfieldName,
XWikiContext context)
Return the FileItem corresponding to the file uploaded for a form field.
|
String |
getFileItem(String formfieldName,
XWikiContext context)
Deprecated.
not well named, use
getFileItemAsString(String, com.xpn.xwiki.XWikiContext) |
String |
getFileItemAsString(String formfieldName,
XWikiContext context)
Allows to retrieve the contents of an uploaded file as a string.
|
byte[] |
getFileItemData(String formfieldName,
XWikiContext context)
Allows to retrieve the contents of an uploaded file as a sequence of bytes.
|
InputStream |
getFileItemInputStream(String formfieldName,
XWikiContext context)
Allows to retrieve the contents of an uploaded file as a stream.
|
List<String> |
getFileItemNames(XWikiContext context)
Retrieves the list of FileItem names.
|
List<org.apache.commons.fileupload.FileItem> |
getFileItems(XWikiContext context)
Allows to retrieve the current list of uploaded files, as a list of
FileItems. |
int |
getFileItemSize(String formfieldName,
XWikiContext context)
Retrieve the size of a file content in byte.
|
String |
getFileName(String formfieldName,
XWikiContext context)
Get the name of the file uploaded for a form field.
|
String |
getName()
The name which can be used for accessing this plugin from
XWiki.getPlugin(String, XWikiContext). |
Api |
getPluginApi(XWikiPluginInterface plugin,
XWikiContext context)
Get a public scriptable API that can be used to call methods of the (privileged) plugin.
|
void |
init(XWikiContext context)
Global initialization, called when the platform is started and the plugin list is initialized.
|
void |
loadFileList(long uploadMaxSize,
int uploadSizeThreshold,
String tempdir,
XWikiContext context)
Loads the list of uploaded files in the context if there are any uploaded files.
|
void |
loadFileList(XWikiContext context)
Loads the list of uploaded files in the context if there are any uploaded files.
|
void |
virtualInit(XWikiContext context)
Initialization method called each time a virtual wiki is started, allowing plugins to perform initialization
tasks needed in each wiki.
|
beginParsing, beginRendering, commonTagsHandler, downloadAttachment, endParsing, endRenderingHandler, flushCache, flushCache, getClassName, getLocalization, insidePREHandler, localizePlainOrKey, outsidePREHandler, setClassName, setName, startRenderingHandlerpublic static final String PLUGIN_NAME
public static final String FILE_LIST_KEY
public static final String UPLOAD_MAXSIZE_PARAMETER
public static final String UPLOAD_SIZETHRESHOLD_PARAMETER
public FileUploadPlugin(String name, String className, XWikiContext context)
name - the plugin nameclassName - the plugin classname (used in logs for example)context - the XWiki ContextXWikiDefaultPlugin(String,String,com.xpn.xwiki.XWikiContext)public String getName()
XWikiPluginInterfaceXWiki.getPlugin(String, XWikiContext).getName in interface XWikiPluginInterfacegetName in class XWikiDefaultPluginpublic void init(XWikiContext context)
XWikiPluginInterfaceinit in interface XWikiPluginInterfaceinit in class XWikiDefaultPlugincontext - the current context, should not be stored since it will become mostly unreliable once the initial
request is terminatedpublic void virtualInit(XWikiContext context)
XWikiPluginInterfacevirtualInit in interface XWikiPluginInterfacevirtualInit in class XWikiDefaultPlugincontext - the current request contextpublic Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context)
XWikiPluginInterfacegetPluginApi in interface XWikiPluginInterfacegetPluginApi in class XWikiDefaultPluginplugin - the plugin instance to wrapcontext - the current request contextnull if the plugin doesn't want to expose a public APIpublic void endRendering(XWikiContext context)
Make sure we don't leave files in temp directories and in memory.
endRendering in interface XWikiPluginInterfaceendRendering in class XWikiDefaultPlugincontext - the current request contextallows to also alter the rendering resultpublic void cleanFileList(XWikiContext context)
context - Context of the request.FileUploadPluginApi.cleanFileList()public void loadFileList(XWikiContext context) throws XWikiException
context - Context of the request.XWikiException - An XWikiException is thrown if the request could not be parsed.FileUploadPluginApi.loadFileList()public void loadFileList(long uploadMaxSize,
int uploadSizeThreshold,
String tempdir,
XWikiContext context)
throws XWikiException
uploadMaxSize - Maximum size of the uploaded files.uploadSizeThreshold - the threshold over which the file data should be stored on disk, and not in memory.tempdir - Temporary directory to store the uploaded files that are not kept in memory.context - Context of the request.XWikiException - if the request could not be parsed, or the maximum file size was reached.FileUploadPluginApi.loadFileList(long, int, String)public List<org.apache.commons.fileupload.FileItem> getFileItems(XWikiContext context)
FileItems.
loadFileList(XWikiContext) needs to be called beforehandcontext - Context of the request.FileUploadPluginApi.getFileItems()public byte[] getFileItemData(String formfieldName, XWikiContext context) throws XWikiException
loadFileList(XWikiContext)
needs to be called beforehand.formfieldName - The name of the form field.context - Context of the request.XWikiException - if the data could not be read.FileUploadPluginApi.getFileItemData(String)public InputStream getFileItemInputStream(String formfieldName, XWikiContext context) throws IOException
loadFileList(XWikiContext) needs to be
called beforehand.formfieldName - The name of the form field.context - Context of the request.IOException - if I/O problem occurspublic int getFileItemSize(String formfieldName, XWikiContext context)
loadFileList(XWikiContext) needs to be called beforehand.formfieldName - The name of the form field.context - Context of the request.public String getFileItemAsString(String formfieldName, XWikiContext context) throws XWikiException
loadFileList(XWikiContext) needs to be
called beforehand.formfieldName - The name of the form field.context - Context of the request.XWikiException - if the data could not be read.FileUploadPluginApi.getFileItemAsString(String)@Deprecated public String getFileItem(String formfieldName, XWikiContext context) throws XWikiException
getFileItemAsString(String, com.xpn.xwiki.XWikiContext)loadFileList(XWikiContext) needs to be
called beforehand.formfieldName - The name of the form field.context - Context of the request.XWikiException - Exception is thrown if the data could not be read.FileUploadPluginApi.getFileItemAsString(String)public List<String> getFileItemNames(XWikiContext context)
loadFileList(XWikiContext) needs to be called beforehand.context - Context of the requestpublic String getFileName(String formfieldName, XWikiContext context)
formfieldName - The name of the form field.context - Context of the request.public org.apache.commons.fileupload.FileItem getFile(String formfieldName, XWikiContext context)
formfieldName - The name of the form field.context - Context of the request.Copyright © 2004–2021 XWiki. All rights reserved.