mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 15:05:50 +01:00
(refs #1816) Apply max_file_size to dropzone as well
This commit is contained in:
@@ -21,12 +21,7 @@ import org.apache.commons.io.{FileUtils, IOUtils}
|
|||||||
*/
|
*/
|
||||||
class FileUploadController extends ScalatraServlet with FileUploadSupport with RepositoryService with AccountService {
|
class FileUploadController extends ScalatraServlet with FileUploadSupport with RepositoryService with AccountService {
|
||||||
|
|
||||||
val maxFileSize = if (System.getProperty("gitbucket.maxFileSize") != null)
|
configureMultipartHandling(MultipartConfig(maxFileSize = Some(FileUtil.MaxFileSize)))
|
||||||
System.getProperty("gitbucket.maxFileSize").toLong
|
|
||||||
else
|
|
||||||
3 * 1024 * 1024
|
|
||||||
|
|
||||||
configureMultipartHandling(MultipartConfig(maxFileSize = Some(maxFileSize)))
|
|
||||||
|
|
||||||
post("/image"){
|
post("/image"){
|
||||||
execute({ (file, fileId) =>
|
execute({ (file, fileId) =>
|
||||||
|
|||||||
@@ -76,4 +76,9 @@ object FileUtil {
|
|||||||
file
|
file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lazy val MaxFileSize = if (System.getProperty("gitbucket.maxFileSize") != null)
|
||||||
|
System.getProperty("gitbucket.maxFileSize").toLong
|
||||||
|
else
|
||||||
|
3 * 1024 * 1024
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ $(function(){
|
|||||||
}
|
}
|
||||||
@dropzone(clickable: Boolean, textareaId: Option[String]) = {
|
@dropzone(clickable: Boolean, textareaId: Option[String]) = {
|
||||||
url: '@context.path/upload/file/@repository.owner/@repository.name',
|
url: '@context.path/upload/file/@repository.owner/@repository.name',
|
||||||
maxFilesize: 10,
|
maxFilesize: @{FileUtil.MaxFileSize / 1024 / 1024},
|
||||||
clickable: @clickable,
|
clickable: @clickable,
|
||||||
previewTemplate: "<div class=\"dz-preview\">\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress>Uploading your files...</span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>",
|
previewTemplate: "<div class=\"dz-preview\">\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress>Uploading your files...</span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>",
|
||||||
success: function(file, id) {
|
success: function(file, id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user