Pārlūkot izejas kodu

图片上传BUG

huangwenjie 5 gadi atpakaļ
vecāks
revīzija
9fd06ae761

+ 10 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/file_upload/FileUploadEndpoint.java

@ -13,6 +13,7 @@ import com.yihu.jw.wlyy.service.WlyyBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -70,7 +71,9 @@ public class FileUploadEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM)
    @ApiOperation(value = "文件流上传文件", notes = "文件流上传文件")
    public ObjEnvelop<UploadVO> uploadStream(@ApiParam(value = "文件", required = true)
                                                 @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
                                                 @RequestParam(value = "file", required = true) MultipartFile file,
                                             @ApiParam(value = "文件", required = true)
                                             @RequestParam(value = "filename", required = false) String filename) throws Exception{
        UploadVO uploadVO = new UploadVO();
        if (isClose.equalsIgnoreCase("1")){
            Map<String, Object> map = fileUploadService.uploadImg(file);
@ -85,6 +88,12 @@ public class FileUploadEndpoint extends EnvelopRestEndpoint {
        }else {
            // 得到文件的完整名称  xxx.txt
            String originalFilename = file.getOriginalFilename();
            
            //判断文件名称是否有包含后缀,及前端是否有传后缀名称,有的话拼接图片后缀
            if(originalFilename.lastIndexOf(".") == 0 && StringUtils.isNotEmpty(filename)){
                originalFilename = originalFilename +"."+filename;
            }
            
            InputStream inputStream = file.getInputStream();
            uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
        }