Skip to content
Snippets Groups Projects
Commit 13c27181 authored by Vincent Massol's avatar Vincent Massol
Browse files

XWIKI-17173: Make the fileupload plugin use the xwiki temporary directory when...

XWIKI-17173: Make the fileupload plugin use the xwiki temporary directory when xwiki.upload.tempdir is not set
parent 59ce538a
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.xwiki.environment.Environment;
import com.xpn.xwiki.XWiki; import com.xpn.xwiki.XWiki;
import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.XWikiContext;
...@@ -44,6 +45,7 @@ ...@@ -44,6 +45,7 @@
import com.xpn.xwiki.api.Api; import com.xpn.xwiki.api.Api;
import com.xpn.xwiki.plugin.XWikiDefaultPlugin; import com.xpn.xwiki.plugin.XWikiDefaultPlugin;
import com.xpn.xwiki.plugin.XWikiPluginInterface; import com.xpn.xwiki.plugin.XWikiPluginInterface;
import com.xpn.xwiki.web.Utils;
/** /**
* Plugin that offers access to uploaded files. The uploaded files are automatically parsed and preserved as a list of * Plugin that offers access to uploaded files. The uploaded files are automatically parsed and preserved as a list of
...@@ -96,6 +98,8 @@ public class FileUploadPlugin extends XWikiDefaultPlugin ...@@ -96,6 +98,8 @@ public class FileUploadPlugin extends XWikiDefaultPlugin
*/ */
private static final long UPLOAD_DEFAULT_SIZETHRESHOLD = 100000L; private static final long UPLOAD_DEFAULT_SIZETHRESHOLD = 100000L;
private Environment environment;
/** /**
* @param name the plugin name * @param name the plugin name
* @param className the plugin classname (used in logs for example) * @param className the plugin classname (used in logs for example)
...@@ -181,7 +185,7 @@ public void loadFileList(XWikiContext context) throws XWikiException ...@@ -181,7 +185,7 @@ public void loadFileList(XWikiContext context) throws XWikiException
loadFileList( loadFileList(
xwiki.getSpacePreferenceAsLong(UPLOAD_MAXSIZE_PARAMETER, UPLOAD_DEFAULT_MAXSIZE, context), xwiki.getSpacePreferenceAsLong(UPLOAD_MAXSIZE_PARAMETER, UPLOAD_DEFAULT_MAXSIZE, context),
(int) xwiki.getSpacePreferenceAsLong(UPLOAD_SIZETHRESHOLD_PARAMETER, UPLOAD_DEFAULT_SIZETHRESHOLD, context), (int) xwiki.getSpacePreferenceAsLong(UPLOAD_SIZETHRESHOLD_PARAMETER, UPLOAD_DEFAULT_SIZETHRESHOLD, context),
xwiki.Param("xwiki.upload.tempdir"), context); xwiki.Param("xwiki.upload.tempdir", getEnvironment().getTemporaryDirectory().getAbsolutePath()), context);
} }
/** /**
...@@ -454,4 +458,12 @@ public FileItem getFile(String formfieldName, XWikiContext context) ...@@ -454,4 +458,12 @@ public FileItem getFile(String formfieldName, XWikiContext context)
return fileitem; return fileitem;
} }
private Environment getEnvironment()
{
if (this.environment == null) {
this.environment = Utils.getComponent(Environment.class);
}
return this.environment;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment