|
@@ -33,7 +33,7 @@ namespace MySystem.Areas.Api.Controllers
|
|
|
return File(stream.ToArray(), "image/gif");
|
|
|
}
|
|
|
#endregion
|
|
|
-
|
|
|
+
|
|
|
#region 图片验证码
|
|
|
public FileContentResult PictureCode(string Tag = "")
|
|
|
{
|
|
@@ -47,26 +47,34 @@ namespace MySystem.Areas.Api.Controllers
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
-
|
|
|
+
|
|
|
#region 前端上传oss返回参数
|
|
|
- public JsonResult OssInfo()
|
|
|
+ public JsonResult OssInfo(string value)
|
|
|
{
|
|
|
+ value = DesDecrypt(value);
|
|
|
+ JsonData data = JsonMapper.ToObject(value);
|
|
|
+ string dir = data["dir"].ToString(); //文件上传路径
|
|
|
+ if (string.IsNullOrEmpty(data["dir"].ToString()))
|
|
|
+ {
|
|
|
+ return Json(new AppResultJson() { Status = "1", Info = "文件上传路径不能为空" });
|
|
|
+ }
|
|
|
Dictionary<string, object> Obj = new Dictionary<string, object>();
|
|
|
var OssUrl = OssHost;
|
|
|
var AccessKeyId = OssKey;
|
|
|
var AccessKeySecret = OssSecret;
|
|
|
+ var endpoint = "https://" + OssEndpoint;
|
|
|
|
|
|
- var dir = DateTime.Now.ToString("yyyyMMdd") + "/"; //上传目录
|
|
|
// 构造OssClient实例。 endpoint 格式:https://oss-cn-beijing.aliyuncs.com
|
|
|
- var ossClient = new OssClient(OssUrl, AccessKeyId, AccessKeySecret);
|
|
|
+ var ossClient = new OssClient(endpoint, AccessKeyId, AccessKeySecret);
|
|
|
var config = new PolicyConditions();
|
|
|
config.AddConditionItem(PolicyConditions.CondContentLengthRange, 1, 1024L * 1024 * 1024 * 5);// 文件大小范围:单位byte
|
|
|
- config.AddConditionItem(PolicyConditions.CondSuccessActionStatus, "200");
|
|
|
config.AddConditionItem(MatchMode.StartWith, PolicyConditions.CondKey, dir);
|
|
|
var expire = DateTimeOffset.Now.AddMinutes(30);// 过期时间
|
|
|
+
|
|
|
// 生成 Policy,并进行 Base64 编码
|
|
|
var policy = ossClient.GeneratePostPolicy(expire.LocalDateTime, config);
|
|
|
var policyBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(policy));
|
|
|
+
|
|
|
// 计算签名
|
|
|
var hmac = new HMACSHA1(Encoding.UTF8.GetBytes(AccessKeySecret));
|
|
|
var bytes = hmac.ComputeHash(Encoding.UTF8.GetBytes(policyBase64));
|
|
@@ -74,10 +82,11 @@ namespace MySystem.Areas.Api.Controllers
|
|
|
|
|
|
Obj.Add("OssUrl", OssUrl);
|
|
|
Obj.Add("AccessKeyId", AccessKeyId);
|
|
|
- Obj.Add("AccessKeySecret", AccessKeySecret);
|
|
|
+ // Obj.Add("AccessKeySecret", AccessKeySecret);
|
|
|
Obj.Add("Policy", policyBase64);
|
|
|
Obj.Add("Expiration", expire);
|
|
|
Obj.Add("Signature", Signature);
|
|
|
+ Obj.Add("dir", dir);
|
|
|
return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
|
|
|
}
|
|
|
#endregion
|
|
@@ -254,7 +263,7 @@ namespace MySystem.Areas.Api.Controllers
|
|
|
public JsonResult LayUIUpload([FromForm] IFormCollection rf, string Path = "", string Resize = "")
|
|
|
{
|
|
|
IFormFile imgFile = rf.Files[0];
|
|
|
- string Icon = MySystemLib.SystemPublicFuction.GetFilePath(imgFile, Path + "/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/",false);
|
|
|
+ string Icon = MySystemLib.SystemPublicFuction.GetFilePath(imgFile, Path + "/" + DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/", false);
|
|
|
string piccut = "";
|
|
|
if (!string.IsNullOrEmpty(Resize) && (imgFile.FileName.ToLower().EndsWith(".png") || imgFile.FileName.EndsWith(".jpg")))
|
|
|
{
|
|
@@ -267,7 +276,7 @@ namespace MySystem.Areas.Api.Controllers
|
|
|
System.IO.File.Delete(function.getPath(Icon));
|
|
|
}
|
|
|
else
|
|
|
- {
|
|
|
+ {
|
|
|
piccut = Icon;
|
|
|
}
|
|
|
return Json(new AppResultJson() { Status = "1", Info = "", Data = piccut });
|