Ejemplo n.º 1
0
 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"));
 }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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"));
        }
Ejemplo n.º 4
0
 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"));
 }