Skip to content

Commit

Permalink
修复#93同样的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou-hao committed Oct 12, 2018
1 parent ac09bbe commit 5c01883
Showing 1 changed file with 1 addition and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ public void init() {

private String getDownloadPath(HttpServletRequest request) {
return rootPath;
// String contextPath = request.getContextPath();
//
// return (StringUtils.hasText(contextPath) || contextPath.equals("/") ? "/" : (contextPath.startsWith("/") ? contextPath : "/" + contextPath) + "/");
}

/**
Expand All @@ -71,21 +68,9 @@ private String getDownloadPath(HttpServletRequest request) {
*/
@RequestMapping(method = RequestMethod.POST, consumes = "multipart/form-data")
@ApiOperation("上传文件")
public String upload(@RequestParam(value = "upfile", required = false) MultipartFile file,HttpServletRequest request) throws IOException {
public String upload(@RequestParam(value = "upfile", required = false) MultipartFile file) throws IOException {
String fileName = file.getOriginalFilename();
String contentType = Optional.ofNullable(request)
.orElseThrow(UnsupportedOperationException::new)
.getContentType();
ParameterParser parser = new ParameterParser();
Map<String, String> params = parser.parse(contentType, ';');
if (params.get("charset") == null) {
try {
fileName = new String(file.getOriginalFilename().getBytes("ISO-8859-1"), "utf-8");
} catch (@SuppressWarnings("all") UnsupportedEncodingException ignore) {
}
}
String suffix = FileType.getSuffixByFilename(fileName);

String path = fileService.saveStaticFile(file.getInputStream(), System.currentTimeMillis() + suffix);
State state = new BaseState(true);
state.putInfo("size", file.getSize());
Expand Down

0 comments on commit 5c01883

Please sign in to comment.