|
@@ -79,16 +79,17 @@ namespace MySystem.Areas.Api.Controllers.v1
|
|
public JsonResult OssInfo()
|
|
public JsonResult OssInfo()
|
|
{
|
|
{
|
|
Dictionary<string, object> Obj = new Dictionary<string, object>();
|
|
Dictionary<string, object> Obj = new Dictionary<string, object>();
|
|
- var OssUrl = "laikeba.oss-cn-chengdu.aliyuncs.com";
|
|
|
|
- var AccessKeyId = "LTA15tJsPaNzgCSMCPwb8zfz";
|
|
|
|
- var AccessKeySecret = "efM31Up75f0cgZ32U6xvAciagceQae";
|
|
|
|
|
|
+ var OssUrl = "oss-cn-chengdu.aliyuncs.com";
|
|
|
|
+ var AccessKeyId = "LTAI5tNfshCAkuZkpxGTEoxb";
|
|
|
|
+ var AccessKeySecret = "gnLlKh1fRUsxf6Bio4b2284ZlqYx4H";
|
|
|
|
|
|
var dir = DateTime.Now.ToString("yyyyMMdd") + "/";
|
|
var dir = DateTime.Now.ToString("yyyyMMdd") + "/";
|
|
// 构造OssClient实例。 endpoint 格式:https://oss-cn-beijing.aliyuncs.com
|
|
// 构造OssClient实例。 endpoint 格式:https://oss-cn-beijing.aliyuncs.com
|
|
- var ossClient = new OssClient("https://" + OssUrl, AccessKeyId, AccessKeySecret);
|
|
|
|
|
|
+ var ossClient = new OssClient(OssUrl, AccessKeyId, AccessKeySecret);
|
|
var config = new PolicyConditions();
|
|
var config = new PolicyConditions();
|
|
config.AddConditionItem(PolicyConditions.CondContentLengthRange, 1, 1024L * 1024 * 1024 * 5);// 文件大小范围:单位byte
|
|
config.AddConditionItem(PolicyConditions.CondContentLengthRange, 1, 1024L * 1024 * 1024 * 5);// 文件大小范围:单位byte
|
|
- config.AddConditionItem(MatchMode.StartWith, PolicyConditions.CondKey, dir);
|
|
|
|
|
|
+ // config.AddConditionItem(MatchMode.StartWith, PolicyConditions.CondKey, dir);
|
|
|
|
+ // config.AddConditionItem(PolicyConditions.CondSuccessActionStatus, "200");
|
|
var expire = DateTimeOffset.Now.AddMinutes(30);// 过期时间
|
|
var expire = DateTimeOffset.Now.AddMinutes(30);// 过期时间
|
|
// 生成 Policy,并进行 Base64 编码
|
|
// 生成 Policy,并进行 Base64 编码
|
|
var policy = ossClient.GeneratePostPolicy(expire.LocalDateTime, config);
|
|
var policy = ossClient.GeneratePostPolicy(expire.LocalDateTime, config);
|
|
@@ -97,10 +98,12 @@ namespace MySystem.Areas.Api.Controllers.v1
|
|
var hmac = new HMACSHA1(Encoding.UTF8.GetBytes(AccessKeySecret));
|
|
var hmac = new HMACSHA1(Encoding.UTF8.GetBytes(AccessKeySecret));
|
|
var bytes = hmac.ComputeHash(Encoding.UTF8.GetBytes(policyBase64));
|
|
var bytes = hmac.ComputeHash(Encoding.UTF8.GetBytes(policyBase64));
|
|
var Signature = Convert.ToBase64String(bytes);
|
|
var Signature = Convert.ToBase64String(bytes);
|
|
|
|
+
|
|
Obj.Add("OssUrl", OssUrl);
|
|
Obj.Add("OssUrl", OssUrl);
|
|
Obj.Add("AccessKeyId", AccessKeyId);
|
|
Obj.Add("AccessKeyId", AccessKeyId);
|
|
Obj.Add("AccessKeySecret", AccessKeySecret);
|
|
Obj.Add("AccessKeySecret", AccessKeySecret);
|
|
Obj.Add("Policy", policyBase64);
|
|
Obj.Add("Policy", policyBase64);
|
|
|
|
+ Obj.Add("Expiration", expire);
|
|
Obj.Add("Signature", Signature);
|
|
Obj.Add("Signature", Signature);
|
|
return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
|
|
return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
|
|
}
|
|
}
|