通过代码上传的图片,一点看连接就是下载,要如何设置,为访问图片了?
file.host=https://lfweixioa-imooc.oss-cn-shanghai.aliyuncs.com/
public String uploadOSS(MultipartFile file, String userId, String fileExtName)
throws Exception {
System.out.println(fileResource.toString());
// 构建ossClient
OSS ossClient = new OSSClientBuilder()
.build(fileResource.getEndpoint(),
fileResource.getAccessKeyId(),
fileResource.getAccessKeySecret());
InputStream inputStream = file.getInputStream();
//随机的ID
String fileName = sid.nextShort();
String myObjectName = fileResource.getObjectName() + "/" + userId + "/"
+ fileName + "." + fileExtName;
ossClient.putObject(fileResource.getBucketName(), myObjectName, inputStream);
ossClient.shutdown();
return myObjectName;
}