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 = "没法读取文件" });

}
相关文章
相关标签/搜索