czt
2024-07-13 bd01ba57ed8526a0ee94a50e1f52034251bb54f6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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<String, Object> 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;
    }
 
}