public ActionResult Upload(HttpPostedFileBase imageUpload) { if (imageUpload != null) { if (!checkFile(Path.GetFileName(imageUpload.FileName))) { TempData["Msg"] = "This file is not an image."; return(RedirectToAction("Upload")); } if (checkFile(Path.GetFileName(imageUpload.FileName)) && (imageUpload.ContentLength > 4194304)) { TempData["Msg"] = "Size of this File is greater than 4MB."; return(RedirectToAction("Upload")); } if (checkFile(Path.GetFileName(imageUpload.FileName)) && (imageUpload.ContentLength > 0 || imageUpload.ContentLength < 4194304)) { CloudBlobContainer blobContainer = BlobStorageService.GetCloudBlobContainer(); CloudBlockBlob blob = blobContainer.GetBlockBlobReference(imageUpload.FileName); blob.UploadFromStream(imageUpload.InputStream); } } else { TempData["Msg"] = "No file is selected."; } return(RedirectToAction("Upload")); }
public ActionResult Upload() { CloudBlobContainer blobContainer = BlobStorageService.GetCloudBlobContainer(); List <string> blods = new List <string>(); blobContainer.ListBlobs().ToList().ForEach(s => blods.Add(s.Uri.ToString())); return(View(blods)); }
public ActionResult DeleteImage(string imageName) { Uri uri = new Uri(imageName); string fileName = Path.GetFileName(uri.LocalPath); CloudBlobContainer blobContainer = BlobStorageService.GetCloudBlobContainer(); CloudBlockBlob blod = blobContainer.GetBlockBlobReference(fileName); blod.Delete(); TempData["Msg"] = "File : " + fileName + "deleted."; return(RedirectToAction("Upload")); }
public ActionResult Upload(HttpPostedFileBase imageUpload) { if (imageUpload != null) { if (imageUpload.ContentLength > 0) { CloudBlobContainer blobContainer = BlobStorageService.GetCloudBlobContainer(); CloudBlockBlob blod = blobContainer.GetBlockBlobReference(imageUpload.FileName); blod.UploadFromStream(imageUpload.InputStream); } } else { TempData["Msg"] = "No file is selected."; } return(RedirectToAction("Upload")); }