package com.ld.igds.file; import java.io.File; import java.io.IOException; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.bstek.dorado.uploader.UploadFile; import com.bstek.dorado.uploader.annotation.FileResolver; import com.ld.igds.util.ContextUtil; /** * dorado7附件上传 * * @author: andy.jia * @description: * @version: * @data:2020年6月24日 * */ @Component public class MyUploadProcessor { @Autowired private CoreFileService fileService; /** * * myUploadProcessor#tempProcess * 上传附件到临时目录,名称自动调整生成,并返回 * * @param file * @param parameter * @return */ @FileResolver public String tempProcess(UploadFile file, Map parameter) { String newFileName = null; try { String basePath = fileService.getTempFilePath(); newFileName = ContextUtil.getUUID() + file.getFileName().substring( file.getFileName().lastIndexOf(".")); file.transferTo(new File(basePath + newFileName)); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return newFileName; } }