.net sdk 图片上传oss后,如何获取原图的缩略图
///
/// 获取下载链接
/// 算法参考:https://help.aliyun.com/document_detail/27135.html?spm=5176.8232292.domaindetail.19.IN2iTT
///
public string GetDownloadUrl(string bucketName, string key, string cdnDomain,
DateTime expireDate, string privateKey, out string msg)
{
msg = string.Empty;
try
{
var ossUri = Clinet.GeneratePresignedUri(bucketName, key, expireDate);
var cdnUrl = BuildCdnRequestUrl(_endpoint, bucketName, ossUri.AbsoluteUri, cdnDomain);
var timestamp = (int)(expireDate - new DateTime(1970, 1, 1)).TotalSeconds;
var rand = new Random().Next();
var md5Value = GetMd5(string.Format('/{0}-{1}-{2}-{3}-{4}', key, timestamp, rand, 0, privateKey));
cdnUrl += string.Format('&auth_key={0}-{1}-{2}-{3}', timestamp, rand, 0, md5Value);
return cdnUrl;
}
catch (Exception ex)
{
msg = ex.Message;
return null;
}
}
赞0
踩0