Skip to content

SpringBoot后端怎么解析二进制串为图片,并将图片上传到腾讯云存储桶上返回连接 #8

Answered by 404name
spcodhu asked this question in 问答板块
Discussion options

You must be logged in to vote

这应该是base64编码的图片. 你的问题很简单,你自己其实思路也都在上面,只是你一下子把东西塞到项目里面肯定难搞,你可以先搞个demo或者test先跑通腾讯云。

  1. 你先另起一个项目,尝试跑通腾讯云。
  2. 然后把腾讯云上传的代码封装成工具放到你的项目里面去。
  3. 到时候就是直接string remoteUrl = UploadImageToTencentCloud.uploadImage(base64File)
上传的具体工具代码,下是chatgpt回答 以下是使用Java进行Base64编码的图片上传腾讯云并且返回图片链接的示例代码:
import com.qcloud.cos.COSClient;
import com.qcloud.cos.model.PutObjectRequest;
import com.qcloud.cos.model.PutObjectResult;
import com.qcloud.cos.region.Region;
import org.apache.commons.codec.binary.Base64;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

public class UploadImageToTencentCloud {

    private static final String SECRET_ID = "your_secret_id";
    private static final String SECRET_KEY = "y…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@spcodhu
Comment options

Answer selected by spcodhu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
好的问题 是一个很好的的问题
2 participants