Package com.xpn.xwiki.web
Class UploadAction
- java.lang.Object
-
- com.xpn.xwiki.web.XWikiAction
-
- com.xpn.xwiki.web.UploadAction
-
- All Implemented Interfaces:
com.xpn.xwiki.internal.web.LegacyAction
@Component @Named("upload") @Singleton public class UploadAction extends XWikiAction
Action that handles uploading document attachments. It saves all the uploaded files whose fieldname start withfilepath
.- Version:
- $Id: 05c049e54ecb6c1f9cbe3c6c747726cad002aeff $
-
-
Field Summary
-
Fields inherited from class com.xpn.xwiki.web.XWikiAction
ACTION_PROGRESS, componentDescriptor, container, execution, observation, waitForXWikiInitialization
-
-
Constructor Summary
Constructors Constructor Description UploadAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
action(XWikiContext context)
protected String
getFileName(String fieldName, FileUploadPlugin fileupload, XWikiContext context)
Extract the corresponding attachment name for a given file field.String
render(XWikiContext context)
boolean
uploadAttachment(String fieldName, String filename, FileUploadPlugin fileupload, XWikiDocument doc, XWikiContext context)
Attach a file to the current document.-
Methods inherited from class com.xpn.xwiki.web.XWikiAction
answerJSON, cleanupComponents, csrfTokenCheck, csrfTokenCheck, execute, execute, getContextualAuthorizationManager, getCurrentMixedDocumentReferenceResolver, getCurrentScriptContext, getEntityNameValidationConfiguration, getEntityNameValidationManager, getFormClass, getLocalization, getLocalSerializer, getName, getProgress, getRealPath, getTranslatedDocument, handleRevision, initializeContainerComponent, initializeXWikiContext, initializeXWikiContext, isEntityReferenceNameValid, localizePlainOrKey, readFromTemplate, resolveTemplate, sendGlobalRedirect, sendRedirect, setContentLength, supportRedirections, writeAjaxErrorResponse
-
-
-
-
Method Detail
-
action
public boolean action(XWikiContext context) throws XWikiException
- Overrides:
action
in classXWikiAction
- Throws:
XWikiException
-
uploadAttachment
public boolean uploadAttachment(String fieldName, String filename, FileUploadPlugin fileupload, XWikiDocument doc, XWikiContext context) throws XWikiException
Attach a file to the current document.- Parameters:
fieldName
- the target file fieldfilename
-fileupload
- theFileUploadPlugin
holding the form datadoc
- the target documentcontext
- the current request context- Returns:
true
if the file was successfully attached,false
otherwise.- Throws:
XWikiException
- if the form data cannot be accessed, or if the database operation failed
-
getFileName
protected String getFileName(String fieldName, FileUploadPlugin fileupload, XWikiContext context) throws XWikiException
Extract the corresponding attachment name for a given file field. It can either be specified in a separate form input field, or it is extracted from the original filename.- Parameters:
fieldName
- the target file fieldfileupload
- theFileUploadPlugin
holding the form datacontext
- the current request context- Returns:
- a valid attachment name
- Throws:
XWikiException
- if the form data cannot be accessed, or if the specified filename is invalid
-
render
public String render(XWikiContext context) throws XWikiException
- Overrides:
render
in classXWikiAction
- Throws:
XWikiException
-
-