我将Azure blob url存储到我的数据库中.可以使用该URL获取blob吗?实际上我需要更新blob,在这样做时我需要验证.所以我需要将该数据库实体模型转换为我的本地模型并对它们应用验证.但在我的本地模型中我有Id,Name,HttpPostedFileBase文件.当我插入blob时,我得到blob url并保存它在database.But如何在更新时检索该blob?这是我的本地模特
public class BlobAppModel
{
public int Id { get; set; }
[Required(ErrorMessage="Please enter the name of the image")]
[Remote("IsNameAvailable","Home",HttpMethod="POST",ErrorMessage="Name Already Exists")]
public string Name { set; get; }
[Required(ErrorMessage="Please select an image file")]
public HttpPostedFileBase File { set; get; }
}
Run Code Online (Sandbox Code Playgroud)
我的实体模型就是这个
public partial class BlobApp
{
public int Id { get; set; }
public string Name { get; set; }
public string Uri { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
当我编辑它时,我需要得到blob ..我被困在这里..任何人都可以帮助我吗?
public ActionResult Edit(string Id)
{ …Run Code Online (Sandbox Code Playgroud) 这是我的型号代码
public class BlobAppModel
{
[Required(ErrorMessage="Please enter the name of the image")]
[Remote("IsNameAvailable","Home",ErrorMessage="Name Already Exists")]
public string Name { set; get; }
}
Run Code Online (Sandbox Code Playgroud)
在我的控制器中我有
public JsonResult IsNameAvailable(string Name)
{
bool xx= BlobManager.IsNameAvailable(Name);
if (!xx)
{
return Json("The name already exists", JsonRequestBehavior.AllowGet);
}
return Json(true, JsonRequestBehavior.AllowGet);
}
Run Code Online (Sandbox Code Playgroud)
在我的数据中我有
public static bool IsNameAvailable(string Name)
{
var test = "";
using (var x = new BlobTestAppDBEntities())
{
try
{
test=x.BlobApps.Where(m => m.Name == Name).FirstOrDefault().Uri;
if (test != null)
return false;
else
return true; …Run Code Online (Sandbox Code Playgroud)