jiangping
2025-04-23 57f7b8ec31174930e479f2fd1847b90741986c4c
server/src/main/java/com/doumee/api/common/PublicCloudController.java
@@ -24,6 +24,7 @@
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartRequest;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import javax.servlet.http.HttpServletRequest;
@@ -73,9 +74,19 @@
    @ApiOperation(value = "批量上传文件到FTP")
    @RequestMapping(method= RequestMethod.POST,value="/uploadBatch")
    @ResponseBody
    public void uploadBatch(@RequestParam("files") MultipartFile[] fileList,HttpServletRequest request, HttpServletResponse response, String folder) throws Exception {
//    public void uploadBatch(@RequestParam("files") MultipartFile[] fileList,HttpServletRequest request, HttpServletResponse response, String folder) throws Exception {
    public void uploadBatch(MultipartRequest request, HttpServletResponse response, String folder) throws Exception {
        if(Objects.isNull(folder)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        Set<String> setList = request.getMultiFileMap().keySet();
        if(Objects.isNull(setList)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        List<MultipartFile>  fileList = new ArrayList<>();
        for(String str:setList){
            List<MultipartFile> fl = request.getMultiFileMap().get(str);
            fileList.addAll(fl);
        }
        if(Objects.isNull(fileList)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
@@ -95,7 +106,7 @@
            context.put("code", 200);
            context.put("errno",0);
               JSONArray jsonArray = new JSONArray();
            if (fileList.length > 0) {
            if (fileList.size() > 0) {
                //遍历文件列表
                Integer index = Constants.ONE;
                for (MultipartFile file :fileList) {
@@ -111,7 +122,7 @@
                    if(StringUtils.equals(Constants.uploadType.blob,uploadType)){
                        r = azureBlobUtil.uploadFileWithResponse( fileName,is);//上传
                    }else{
                        r = ftp.uploadInputstreamBatch(is, fileName, Constants.equalsInteger(index ,fileList.length),index);
                        r = ftp.uploadInputstreamBatch(is, fileName, Constants.equalsInteger(index ,fileList.size()),index);
                    }
                    if (r) {
                        JSONObject fileJSON = new JSONObject();