我将 Azure blob url 存储到我的数据库中。我可以使用该 url 获取 blob 吗?实际上我需要更新 blob,同时我需要验证。所以我需要将该数据库实体模型转换为我的本地模型并为它们应用验证。但是在我的本地模型中,我有 Id、Name、HttpPostedFileBase 文件。当我插入 blob 时,我得到 blob url 并保存它在数据库中。但是如何在更新时检索该 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; }
}
我的实体模型就是这个
public partial class BlobApp
{
public int Id { get; set; }
public string Name { get; set; }
public string Uri { get; set; }
}
当我编辑它时,我需要获取 blob ..我被困在这里..有人可以帮我吗?
public ActionResult Edit(string Id)
{
var data=BlobManager.GetBlob(Convert.ToInt32(Id));
BlobStorageServices _blobstorageservice = new BlobStorageServices();
CloudBlobContainer container = _blobstorageservice.GetCloudBlobContainer();
CloudBlockBlob blob = container.GetBlockBlobReference(data.Uri.ToString());
BlobAppModel model = new BlobAppModel { Id = data.Id, Name = data.Name, File =//This is where I need to get the file//};
return View("Edit",BlobManager.GetBlob(Convert.ToInt32(Id)));
}