Commit efa9fa81 authored by Ryan Loong's avatar Ryan Loong

fix 文件导出

parent a5fc2b61
...@@ -27,6 +27,7 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -27,6 +27,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -161,7 +162,7 @@ public class WxStorageController { ...@@ -161,7 +162,7 @@ public class WxStorageController {
* @return * @return
*/ */
@GetMapping("/fetch/{key:.+}") @GetMapping("/fetch/{key:.+}")
public ResponseEntity<Resource> fetch(@PathVariable String key) { public ResponseEntity<Resource> fetch(@PathVariable String key) throws UnsupportedEncodingException {
if (key == null) { if (key == null) {
return ResponseEntity.notFound().build(); return ResponseEntity.notFound().build();
} }
...@@ -189,7 +190,7 @@ public class WxStorageController { ...@@ -189,7 +190,7 @@ public class WxStorageController {
ResponseEntity.notFound(); ResponseEntity.notFound();
} }
return ResponseEntity.ok().contentType(mediaType).header(HttpHeaders.CONTENT_DISPOSITION, return ResponseEntity.ok().contentType(mediaType).header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + storage.getName() + "\"").body(file); "attachment; filename=\"" + URLEncoder.encode(storage.getName(), "UTF-8") + "\"").body(file);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment