优化 Upload 文件上传组件一些参数,默认从后台获取

This commit is contained in:
thinkgem
2025-10-27 09:15:11 +08:00
parent c88a576219
commit 5e01b22fb9
2 changed files with 14 additions and 9 deletions

View File

@@ -10,15 +10,15 @@ import com.jeesite.common.web.BaseController;
import com.jeesite.modules.file.entity.FileUpload;
import com.jeesite.modules.file.entity.FileUploadParams;
import com.jeesite.modules.file.service.FileUploadService;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
@@ -45,14 +45,19 @@ public class FileUploadController extends BaseController {
@ResponseBody
public Map<String, Object> params() {
Map<String, Object> model = MapUtils.newHashMap();
model.put("maxFileSize", Global.getConfigToLong("file.maxFileSize", "500*1024*1024"));
model.put("imageAllowSuffixes", Global.getConfig("file.imageAllowSuffixes", FileUploadParams.DEFAULT_IMAGE_ALLOW_SUFFIXES));
model.put("mediaAllowSuffixes", Global.getConfig("file.mediaAllowSuffixes", FileUploadParams.DEFAULT_MEDIA_ALLOW_SUFFIXES));
model.put("fileAllowSuffixes", Global.getConfig("file.fileAllowSuffixes", FileUploadParams.DEFAULT_FILE_ALLOW_SUFFIXES));
model.put("chunked", Global.getConfig("file.chunked", "true"));
model.put("chunkSize", Global.getConfigToInteger("file.chunkSize", "10*1024*1024"));
model.put("threads", Global.getConfigToInteger("file.threads", "3"));
model.put("imageMaxWidth", Global.getConfigToInteger("file.imageMaxWidth", "1024"));
model.put("imageMaxHeight", Global.getConfigToInteger("file.imageMaxHeight", "768"));
model.put("checkmd5", Global.getConfigToBoolean("file.checkmd5", "true"));
model.put("chunked", Global.getConfigToBoolean("file.chunked", "true"));
model.put("chunkSize", Global.getConfigToInteger("file.chunkSize", "10*1024*1024"));
model.put("threads", Global.getConfigToInteger("file.threads", "3"));
return model;
}

View File

@@ -161,9 +161,9 @@ $(function() {
fileNameInputId: '${p.fileNameInputId}',
uploadType: '${p.uploadType}',
maxFileSize: "#{isNotBlank(p.maxFileSize)?p.maxFileSize:@Global.getConfig('file.maxFileSize', '500*1024*1024')}",
imageAllowSuffixes: '${isNotBlank(p.allowSuffixes)?p.allowSuffixes:@Global.getConfig("file.imageAllowSuffixes", ".gif,.bmp,.jpeg,.jpg,.ico,.png,.tif,.tiff,.webp,")}',
mediaAllowSuffixes: '${isNotBlank(p.allowSuffixes)?p.allowSuffixes:@Global.getConfig("file.mediaAllowSuffixes", ".flv,.swf,.mkv,webm,.mid,.mov,.mp3,.mp4,.m4v,.mpc,.mpeg,.mpg,.swf,.wav,.wma,.wmv,.avi,.rm,.rmi,.rmvb,.aiff,.asf,.ogg,.ogv,")}',
fileAllowSuffixes: '${isNotBlank(p.allowSuffixes)?p.allowSuffixes:@Global.getConfig("file.fileAllowSuffixes", ".doc,.docx,.rtf,.xls,.xlsx,.csv,.ppt,.pptx,.pdf,.ofd,.vsd,.txt,.md,.xml,.rar,.zip,.7z,.tar,.tgz,.jar,.gz,.gzip,.bz2,.cab,.iso,")}',
imageAllowSuffixes: '${isNotBlank(p.allowSuffixes)?p.allowSuffixes:@Global.getConfig("file.imageAllowSuffixes", @com.jeesite.modules.file.entity.FileUploadParams.DEFAULT_IMAGE_ALLOW_SUFFIXES)}',
mediaAllowSuffixes: '${isNotBlank(p.allowSuffixes)?p.allowSuffixes:@Global.getConfig("file.mediaAllowSuffixes", @com.jeesite.modules.file.entity.FileUploadParams.DEFAULT_MEDIA_ALLOW_SUFFIXES)}',
fileAllowSuffixes: '${isNotBlank(p.allowSuffixes)?p.allowSuffixes:@Global.getConfig("file.fileAllowSuffixes", @com.jeesite.modules.file.entity.FileUploadParams.DEFAULT_FILE_ALLOW_SUFFIXES)}',
chunked: "#{__info_type=='0'?false:@Global.getConfig('file.chunked', 'true')}",
chunkSize: "#{@Global.getConfigToInteger('file.chunkSize', '10*1024*1024')}",
threads: "#{@Global.getConfigToInteger('file.threads', '3')}",