diff --git a/README.md b/README.md index 0f86545..6ee2f01 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,12 @@ - `--host=[HOSTNAME]` - `--gitbucket.home=[DATA_DIR]` - `--temp_dir=[TEMP_DIR]` +- `--max_file_size=[MAX_FILE_SIZE]` `TEMP_DIR` is used as the [temporary directory for the jetty application context](https://www.eclipse.org/jetty/documentation/9.3.x/ref-temporary-directories.html). This is the directory into which the `gitbucket.war` file is unpacked, the source files are compiled, etc. If given this parameter **must** match the path of an existing directory or the application will quit reporting an error; if not given the path used will be a `tmp` directory inside the gitbucket home. +`MAX_FILE_SIZE` is the max file size for upload files. + You can also deploy `gitbucket.war` to a servlet container which supports Servlet 3.0 (like Jetty, Tomcat, JBoss, etc) For more information about installation on Mac or Windows Server (with IIS), or configuration of Apache or Nginx and also integration with other tools or services such as Jenkins or Slack, see [Wiki](https://github.com/gitbucket/gitbucket/wiki). diff --git a/src/main/java/JettyLauncher.java b/src/main/java/JettyLauncher.java index 74d280d..8b91e91 100644 --- a/src/main/java/JettyLauncher.java +++ b/src/main/java/JettyLauncher.java @@ -39,6 +39,9 @@ contextPath = "/" + contextPath; } break; + case "--max_file_size": + System.setProperty("gitbucket.maxFileSize", dim[2]); + break; case "--gitbucket.home": System.setProperty("gitbucket.home", dim[1]); break; diff --git a/src/main/scala/gitbucket/core/controller/FileUploadController.scala b/src/main/scala/gitbucket/core/controller/FileUploadController.scala index b3926fe..9f27caa 100644 --- a/src/main/scala/gitbucket/core/controller/FileUploadController.scala +++ b/src/main/scala/gitbucket/core/controller/FileUploadController.scala @@ -22,7 +22,12 @@ */ class FileUploadController extends ScalatraServlet with FileUploadSupport with RepositoryService with AccountService { - configureMultipartHandling(MultipartConfig(maxFileSize = Some(3 * 1024 * 1024))) + val maxFileSize = if (System.getProperty("gitbucket.maxFileSize") != null) + System.getProperty("gitbucket.maxFileSize").toLong + else + 3 * 1024 * 1024 + + configureMultipartHandling(MultipartConfig(maxFileSize = Some(maxFileSize))) post("/image"){ execute({ (file, fileId) =>