|
|
@@ -0,0 +1,63 @@
|
|
|
+package cn.reghao.dfs.web.controller;
|
|
|
+
|
|
|
+import cn.reghao.jutil.jdk.result.WebResult;
|
|
|
+import cn.reghao.dfs.web.model.dto.Policy;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author reghao
|
|
|
+ * @date 2023-04-21 13:08:05
|
|
|
+ */
|
|
|
+@Api(tags = "签名接口")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/ajax")
|
|
|
+public class SignController {
|
|
|
+ @ApiOperation("获取存储桶的策略配置")
|
|
|
+ @GetMapping(value = "/policy", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String getBucketPolicy() {
|
|
|
+ Policy policy = new Policy();
|
|
|
+ policy.setExpiration(LocalDateTime.now().toString());
|
|
|
+
|
|
|
+ List<Object> conditions = new ArrayList<>();
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("bucket", "chengdu");
|
|
|
+ map.put("acl", "public-read");
|
|
|
+ map.put("success_action_redirect", "sigv4examplebucket");
|
|
|
+ map.put("x-amz-meta-uuid", "sigv4examplebucket");
|
|
|
+ map.put("x-amz-server-side-encryption", "sigv4examplebucket");
|
|
|
+ map.put("x-amz-credential", "sigv4examplebucket");
|
|
|
+ map.put("x-amz-algorithm", "sigv4examplebucket");
|
|
|
+ map.put("x-amz-date", "sigv4examplebucket");
|
|
|
+ conditions.add(map);
|
|
|
+
|
|
|
+ List<String> list1 = new ArrayList<>();
|
|
|
+ list1.add("starts-with");
|
|
|
+ list1.add("$key");
|
|
|
+ list1.add("user/user1/");
|
|
|
+ conditions.add(list1);
|
|
|
+
|
|
|
+ List<String> list2 = new ArrayList<>();
|
|
|
+ list2.add("starts-with");
|
|
|
+ list2.add("$Content-Type");
|
|
|
+ list2.add("image/");
|
|
|
+ conditions.add(list2);
|
|
|
+
|
|
|
+ List<String> list3 = new ArrayList<>();
|
|
|
+ list3.add("starts-with");
|
|
|
+ list3.add("$x-amz-meta-tag");
|
|
|
+ list3.add("");
|
|
|
+ conditions.add(list3);
|
|
|
+ return WebResult.success(conditions);
|
|
|
+ }
|
|
|
+}
|