Example #1
0
        public ActionResult Post(int parkId, string description, string filename)
        {
            var parkImage = new ParkImage()
            {
                ParkId = parkId, Description = description, Filename = filename
            
            };

            var videoFile = Request.Files[0];

            SaveImage(videoFile.InputStream, parkImage);
            return Json(parkImage);
        }
Example #2
0
        private void SaveImage(Stream stream, ParkImage image)
        {
            var account = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("ConnectionString"));

            var client = account.CreateCloudBlobClient();

            var container = client.GetContainerReference("parkimgs");

            container.CreateIfNotExists(BlobContainerPublicAccessType.Blob);

            var blockBlob = container.GetBlockBlobReference(image.Filename);
            //var blockBlob = container.GetBlockBlobReference("aaaa.mp4");
            blockBlob.Metadata["ParkId"] = image.ParkId.ToString();
            blockBlob.Metadata["Description"] = image.Description;
            blockBlob.UploadFromStream(stream);
            image.ImageUri = blockBlob.Uri.ToString();
            image.ContentType = blockBlob.Properties.ContentType;
        }