Aliyun OSS, opens the image address and cannot be previewed. Download it directly.

Aliyun OSS, opens the image address can not be previewed, directly downloaded, has been bound to the oss domain name, and the record has been approved, is there any great god to point out! Thank you!

Oss
Apr.23,2021

Java SDK solves the following

String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
String accessKeyId = "<yourAccessKeyId>";
String accessKeySecret = "<yourAccessKeySecret>";

OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

InputStream inputStream = new URL("https://www.aliyun.com/").openStream();
//  ContentType
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setContentType("image/jpg");
ossClient.putObject("<yourBucketName>", "<yourObjectName>", inputStream, objectMetadata);

ossClient.shutdown();

check Content-Disposition
and content-type


if you encounter the same problem, we are also trying to solve it. However, the common method is to add '.JPG', but we are three-terminal parallel, so we cannot add a suffix. We have not thought of a reasonable solution yet


when uploading (putObject), just input objectMetadata, to set the appropriate contentType. ObjectMetadata.setContentType ("image/jpg");

Menu