File tree Expand file tree Collapse file tree 1 file changed +3
-0
lines changed
pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change 20
20
import cn .hutool .core .io .IoUtil ;
21
21
import cn .hutool .core .util .IdUtil ;
22
22
import cn .hutool .core .util .StrUtil ;
23
+ import cn .hutool .core .util .URLUtil ;
23
24
import com .amazonaws .services .s3 .model .S3Object ;
24
25
import com .baomidou .mybatisplus .extension .service .impl .ServiceImpl ;
25
26
import com .pig4cloud .pig .admin .api .entity .SysFile ;
32
33
import lombok .AllArgsConstructor ;
33
34
import lombok .SneakyThrows ;
34
35
import lombok .extern .slf4j .Slf4j ;
36
+ import org .springframework .http .HttpHeaders ;
35
37
import org .springframework .stereotype .Service ;
36
38
import org .springframework .transaction .annotation .Transactional ;
37
39
import org .springframework .web .multipart .MultipartFile ;
@@ -91,6 +93,7 @@ public R uploadFile(MultipartFile file) {
91
93
public void getFile (String bucket , String fileName , HttpServletResponse response ) {
92
94
try (S3Object s3Object = fileTemplate .getObject (bucket , fileName )) {
93
95
response .setContentType ("application/octet-stream; charset=UTF-8" );
96
+ response .addHeader (HttpHeaders .CONTENT_DISPOSITION , "attachment; filename=" + URLUtil .encode (fileName ));
94
97
IoUtil .copy (s3Object .getObjectContent (), response .getOutputStream ());
95
98
}
96
99
catch (Exception e ) {
You can’t perform that action at this time.
0 commit comments