|
@@ -18,16 +18,12 @@ import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
-import java.net.URLDecoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
|
/**
|
|
@@ -90,7 +86,7 @@ public class SysFileController
|
|
|
// 上传并返回访问地址
|
|
|
obsClient = new ObsClient(obsConfig.getAK(), obsConfig.getSK(), obsConfig.getENDPOINT());
|
|
|
PutObjectResult putObjectResult = obsClient.putObject(obsConfig.getBUCKET_NAME(),
|
|
|
- "mz/" + objectKey, file.getInputStream());
|
|
|
+ "mzylfwobs/" + objectKey, file.getInputStream());
|
|
|
sysFile.setName(putObjectResult.getObjectKey());
|
|
|
sysFile.setUrl(putObjectResult.getObjectUrl());
|
|
|
return R.ok(sysFile);
|
|
@@ -186,12 +182,12 @@ public class SysFileController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/commonPreview")
|
|
|
- public void commonPreview(String objectKey, HttpServletResponse resp) {
|
|
|
+ @GetMapping("/mzylfwobs/{year}/{month}/{day}/{fileName}")
|
|
|
+ public void commonPreview(@PathVariable("year") String year, @PathVariable("month") String month,
|
|
|
+ @PathVariable("day") String day, @PathVariable("fileName") String fileName, HttpServletResponse resp) {
|
|
|
try {
|
|
|
- objectKey = URLDecoder.decode(objectKey, "utf-8");
|
|
|
- String[] arr = objectKey.split("/");
|
|
|
- String fileName = arr[arr.length - 1];
|
|
|
+// objectKey = URLDecoder.decode(objectKey, "utf-8");
|
|
|
+ String objectKey = "mzylfwobs/" + year + "/" + month + "/" + day + "/" + fileName;
|
|
|
int index = fileName.lastIndexOf(".");
|
|
|
char[] ch = fileName.toCharArray();
|
|
|
String lastString = String.copyValueOf(ch, index + 1, ch.length - index - 1);
|
|
@@ -205,7 +201,7 @@ public class SysFileController
|
|
|
convertOutputStream2(resp, obsConfig.getBUCKET_NAME(), objectKey);
|
|
|
} catch (Exception e) {
|
|
|
log.error("取得文件失败==》", e);
|
|
|
- e.printStackTrace();
|
|
|
+// e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|