OSS上传文件(二)

[HttpPost]
public ActionResult ConfirmUpload()
{
string businessId = Request["businessId"];
string businessType = Request["businessType"];
string itemId = Request["itemId"];
if (string.IsNullOrEmpty(businessId) || string.IsNullOrEmpty(businessType) || string.IsNullOrEmpty(itemId))
return Json(new { success = false, content = "缺少关键参数" });
if (Request.Files != null)
{
try
{
for (int i = 0; i < Request.Files.Count; i++)
{
if (Request.Files[i].FileName != "")
{
HttpPostedFileBase file = Request.Files[i];
var steam = file.InputStream;
AliyunOSS.PutObject(bucketName, "不符合项/" + file.FileName, steam);

//写入文件表

 文件路径="相对路径/" +file.FileName

}
}
return Json(new { success = true, content = "" });
}
catch
{
return Json(new { success = false, content = "" });
}
}
return Json(new { success = false, content = "无法读取文件" });

}

 

posted @ 2019-09-30 17:16  艺洁  阅读(361)  评论(0编辑  收藏  举报