I store the Azure blob url in my database. Can I get blob using this url? Actually I need to update blob, and at the same time I need validations. Therefore, I need to convert this database entity model to my local model and apply validations for them. But in my local model, I have an Id file, Name, HttpPostedFileBase. When I insert blob, I get url blob and save it in the database. But how to get this blob when updating? This is my local model.
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; } }
My essential model is
public partial class BlobApp { public int Id { get; set; } public string Name { get; set; } public string Uri { get; set; } }
When I edit it, I need to get a blob .. I am stuck here. Can anyone help me out?
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))); }
asp.net-mvc blob azure-storage-blobs model-validation
Bharat bhushan
source share