欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 建筑 > 腾讯云COS直传,官方后端demo,GO语言转JAVA

腾讯云COS直传,官方后端demo,GO语言转JAVA

2025/4/19 8:18:34 来源:https://blog.csdn.net/u012229791/article/details/147208462  浏览:    关键词:腾讯云COS直传,官方后端demo,GO语言转JAVA

腾讯云COS直传,官方后端demo,GO写的,我们台是JAVA所以转一下,已跑通。废话不多说,直接上代码:

Controller类如下:

import com.ruoyi.web.core.config.CosConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.*;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

@RestController
@CrossOrigin(origins = "http://127.0.0.1:8080", allowedHeaders = "origin,accept,content-type")
@RequestMapping
public class CosController {

    @Autowired
    private CosConfig config;

    @GetMapping("/post-policy")
    public ResponseEntity<Map<String, Object>> getPostPolicy(@RequestParam String ext) {
        // 判断异常情况
        if (config.getSecretId() == null || config.getSecretKey() == null) {
            return buildErrorResponse("-1", "secretId or secretKey not ready");
        }
        if (config.getBucket() == null || config.getR

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词