瀏覽代碼

init test bucket

zhangchenm 1 月之前
父節點
當前提交
d774ab30de

+ 5 - 3
trade-client/src/main/java/com/trade/client/file/OSSFileStorageController.java

@@ -4,11 +4,13 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.trade.common.core.domain.ResponseResult;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
 import com.trade.service.filestorage.enums.FileModuleEnum;
@@ -19,7 +21,7 @@ import com.trade.service.filestorage.service.OSSFileService;
  * oss文件存储 前端控制器
  * </p>
  */
-@Controller
+@RestController
 @RequestMapping("/file_storage_oss")
 public class OSSFileStorageController {
 
@@ -30,8 +32,8 @@ public class OSSFileStorageController {
      * 单个文件上传
      */
     @RequestMapping(value = "/singleUpload")
-    public Long uploadFile(@RequestParam("file") MultipartFile file, FileModuleEnum moduleDict) {
-        return fileService.uploadFile(file, moduleDict);
+    public ResponseResult<Long> uploadFile(@RequestParam("file") MultipartFile file, FileModuleEnum moduleDict) {
+        return ResponseResult.success(fileService.uploadFile(file, moduleDict));
     }
 
     /**

+ 4 - 5
trade-service/src/main/java/com/trade/service/filestorage/util/oss/OSSUtil.java

@@ -28,22 +28,21 @@ public class OSSUtil {
     public static final String fileSep = "/";// 目录分隔符
     private static final Logger logger = LogManager.getLogger(OSSUtil.class);
     // 北京2节点
-    private static String endpoint = "http://oss-cn-beijing.aliyuncs.com";
+    private static final String endpoint = "http://oss-cn-beijing.aliyuncs.com";
     // 北京2节点
-    private static String internalEndpoint = "http://oss-cn-beijing-internal.aliyuncs.com";
+    private static final String internalEndpoint = "http://oss-cn-beijing-internal.aliyuncs.com";
     @Value("${oss.accessKeyId}")
     private String accessKeyId;
     @Value("${oss.accessKeySecret}")
     private String accessKeySecret;
     // 默认使用一个bucket
-    private static String bucketName = "wet-bucket";
-    private static String key = "trade-platform";
+    private static final String bucketName = "trade-plat";
 
     private OSS internalOSS() {
         return new OSSClientBuilder().build(internalEndpoint, accessKeyId, accessKeySecret);
     }
 
-    private  OSS initOSS() {
+    private OSS initOSS() {
         return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
     }