使用ng flow上传多个文件

dsf9zpds  于 2021-07-09  发布在  Java
关注(0)|答案(0)|浏览(173)

我们的应用程序使用ng flow上传文件。当我们尝试上传多个文件时,它会对每个文件进行单独的后端调用。所以,如果我们上传100个文件,就会有100个后端服务调用。有没有一种方法可以将数组或文件列表发送到控制器?
下面是代码段:

<div data-flow-object="testModel.documentsFlowObject"
                 data-flow-files-submitted="testModel.validateAndUpload($files, $event, $flow)"
                 data-flow-file-success="testModel.documentUploadSuccess($file, $message, $flow)"
                 data-flow-file-error="testModel.documentUploadError($file, $message, $flow)"
                 data-flow-init>

function validateAndUpload(files,$event,flow)
        {
            checkAllFiles(files); // Few validations
            for(var file in files)
            {
            // Flag is set based on validation
                var fileName = formatFileName(files[file].name);
                if(checkFileNames(fileName)===false)
                {                  
                    testModel.uploadFlag=false;
                    break;
                }
                else
                {
                    setDocumentUploadPath();
                    testModel.uploadFlag = true;
                }
            }
            if(testModel.uploadFlag===false )
            {
                $event.preventDefault();
                resetDocumentsUpload(files, $event, flow);
            }
            else
            {
                LoadingModalService.open();
                flow.upload();
            }

        }

mvc控制器:

@RequestMapping(value = "/documents/{id}", method = POST)
        public ResponseEntity<?> uploadDocument(@PathVariable String id, @RequestParam("docIds") List<String> docIds, @RequestParam("file") MultipartFile file) {

有没有办法通过ng流获取请求中的list或multipartfile[]?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题