locked
Azure file upload RRS feed

  • Question

  • I have to upload image to azure blob.Image is uploading but with headers so i am not able to download the image PLEASE HELP me

    here is my code

                    if (httpRequest.Files.Count > 0)
                    {

                        //var FilePath = HttpContext.Current.Server.MapPath("~/Uploads/Students/" + studentId + "/Profile/");
                        foreach (string file in httpRequest.Files)
                        {
                            string extension = System.IO.Path.GetExtension(httpRequest.Files[file].FileName);
                            // Create storagecredentials object by reading the values from the configuration (appsettings.json)

                            StorageCredentials storageCredentials = new StorageCredentials(_storageConfig.AccountName, _storageConfig.AccountKey);

                            // Create cloudstorage account by passing the storagecredentials
                            CloudStorageAccount storageAccount = new CloudStorageAccount(storageCredentials, true);

                            // Create the blob client.
                            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

                            // Get reference to the blob container by passing the name by reading the value from the configuration (appsettings.json)
                            CloudBlobContainer container = blobClient.GetContainerReference(_storageConfig.ImageContainer);

                            // Get the reference to the block blob from the container


                            string fileName = httpRequest.Files[file].FileName;

                            CloudBlockBlob blockBlob = container.GetBlockBlobReference(fileName);
                            using (var s = HttpContext.Current.Request.InputStream)
                            {
                                blockBlob.UploadFromStream(s);
                              }

    Thursday, November 8, 2018 12:29 AM