Ejemplo n.º 1
0
        public ActionResult BrowseImages()
        {
            IEnumerable <IListBlobItem> items = AzureBlobSA.GetContainerFiles(AzureBlobSA.TEST_CONTAINER);
            List <string> urls = new List <string>();

            foreach (var item in items)
            {
                if (item is CloudBlockBlob)
                {
                    var blob = (CloudBlockBlob)item;
                    urls.Add(blob.Name);
                }
            }
            ViewBag.BlobFiles = urls;
            ViewBag.Sas       = AzureBlobSA.GetSasUrl(AzureBlobSA.TEST_CONTAINER);
            return(View());
        }
Ejemplo n.º 2
0
        public object UploadImage(HttpPostedFileBase File)
        {
            if (File == null || File.ContentLength == 0)
            {
                return("error:null");
            }
            var name = "";//AzureBlobSA.UploadImage(AzureBlobSA.REFUND_FILES_CONTAINER, File);

            return(new
            {
                name,
                path = GetImagePath(
                    AzureBlobSA.EncodeTo64(name),
                    AzureBlobSA.GetSasUrl(AzureBlobSA.REFUND_FILES_CONTAINER)
                    )
            });
        }
Ejemplo n.º 3
0
        public ActionResult ImportImage(HttpPostedFileBase Image)
        {
            string path = @"D:\Temp\";

            if (Image == null)
            {
                Error("Failed to upload image");
            }
            else
            {
                var name = AzureBlobSA.UploadImage(AzureBlobSA.TEST_CONTAINER, Image.InputStream, Image.FileName, Image.ContentType);
                Success(String.Format("Got image {0} of type {1} and size {2} {3} {4}",
                                      Image.FileName, Image.ContentType, Image.ContentLength, name,
                                      HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Authority + Url.Action("GetImage", new
                {
                    id  = AzureBlobSA.EncodeTo64(name),
                    sas = AzureBlobSA.GetSasUrl(AzureBlobSA.TEST_CONTAINER)
                })));
            }
            return(RedirectToAction("Index"));
        }