这是我使用 aws s3 sdk 从 Spring Boot 将图像上传到数字海洋的代码
AWSCredentialsProvider awscp = new AWSStaticCredentialsProvider(
new BasicAWSCredentials("clientId", "client_secret")
);
AmazonS3 space = AmazonS3ClientBuilder
.standard()
.withCredentials(awscp)
.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration("https://myproject.fra1.digitaloceanspaces.com", "fra1")
)
.build();
byte[] byteImage = Base64.getMimeDecoder().decode(data.filePath.split(",")[1]);
InputStream is = new ByteArrayInputStream(byteImage);
ObjectMetadata om = new ObjectMetadata();
om.setContentLength(byteImage.length);
om.setContentType("image/jpg");
String filepath = "/images/"+ System.currentTimeMillis()+".jpg";
space.putObject("myproject", filepath, is, om);
但这是给 InvocationTargetException: 400 bad request
我正在从我的本地机器上传,我已经为 * 设置了 cors
这段代码有什么问题