OSS前端压缩图 预览图

oss上传后,获得压缩图地址
(根据阿里官网api pdf 格式是无法压缩预览,请注意)
/**
* 根据图片保存key生成缩略图预览链接
* @param filePath 阿里云图片保存key
* @return 缩略图预览url
*/
public String getSignedUrl(String filePath) {
// 创建OSSClient实例
OSS ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
// 设置图片处理样式,等比缩放,高度630
String style = “image/resize,m_lfit,h_630”;
// 指定过期时间为1小时
Date expiration = new Date(new Date().getTime() + 3600 * 10000);
GeneratePresignedUrlRequest req = new GeneratePresignedUrlRequest(bucketName, filePath, HttpMethod.GET);
req.setExpiration(expiration);
req.setProcess(style);
String signedUrl = ossClient.generatePresignedUrl(req).toString();
return signedUrl;
}

猜你喜欢

转载自blog.csdn.net/weixin_43830876/article/details/102961203