OSSAuditController.java 1.1 KB

123456789101112131415161718192021222324252627282930
  1. package com.izouma.nineth.web;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.aliyun.cdn20180510.Client;
  5. import com.aliyun.cdn20180510.models.RefreshObjectCachesRequest;
  6. import com.aliyun.cdn20180510.models.RefreshObjectCachesResponse;
  7. import com.aliyun.teaopenapi.models.Config;
  8. import lombok.AllArgsConstructor;
  9. import lombok.extern.slf4j.Slf4j;
  10. import org.springframework.web.bind.annotation.PostMapping;
  11. import org.springframework.web.bind.annotation.RestController;
  12. @RestController
  13. @Slf4j
  14. @AllArgsConstructor
  15. public class OSSAuditController {
  16. private Client cdnClient;
  17. @PostMapping("/ossNotify")
  18. public String ossNotify(String checksum, String content) throws Exception {
  19. JSONObject jsonObject = JSON.parseObject(content);
  20. RefreshObjectCachesRequest refreshObjectCachesRequest = new RefreshObjectCachesRequest();
  21. refreshObjectCachesRequest.setObjectPath("cdn.raex.vip/" + jsonObject.getString("object"));
  22. RefreshObjectCachesResponse resp = cdnClient.refreshObjectCaches(refreshObjectCachesRequest);
  23. log.info(JSON.toJSONString(resp, true));
  24. return "ok";
  25. }
  26. }