How to upload Multiple images at a time to AZURE using MVC4?

Posted by Mandlaa under ASP.NET MVC on 1/3/2014 | Points: 10 | Views : 1796 | Status : [Member] | Replies : 1
public ActionResult Create(HttpPostedFileBase[] MultipleFiles)
{
MyBlobStorageService4 _myBlobStorageService = new MyBlobStorageService4();
foreach (var fileBase in MultipleFiles)
{
if (fileBase.ContentLength > 0)
{
Microsoft.WindowsAzure.StorageClient.CloudBlobContainer blobContainer = _myBlobStorageService.GetCloudBlobContainer();
CloudBlob blob = blobContainer.GetBlobReference(fileBase.FileName);
blob.UploadFromStream(fileBase.InputStream);
}
}
return View();
}

MyBlobStorageService4:

public class MyBlobStorageService4
{
public Microsoft.WindowsAzure.StorageClient.CloudBlobContainer GetCloudBlobContainer()
{
Microsoft.WindowsAzure.CloudStorageAccount storageAccount = Microsoft.WindowsAzure.CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString4"));

Microsoft.WindowsAzure.StorageClient.CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

Microsoft.WindowsAzure.StorageClient.CloudBlobContainer blobContainer = blobClient.GetContainerReference("new");


if (blobContainer.CreateIfNotExist())
{
blobContainer.SetPermissions(
new Microsoft.WindowsAzure.StorageClient.BlobContainerPermissions { PublicAccess = Microsoft.WindowsAzure.StorageClient.BlobContainerPublicAccessType.Blob }
);
}

return blobContainer;
}
}

View:

@{
ViewBag.Title = "UploadFile";
}
<h1>Upload a File</h1>
@using (Html.BeginForm("Create", "Addnew", FormMethod.Post,
new { enctype = "multipart/form-data" }))
{
<input type="file" id="FileUploader" name="FileUploader" multiple="multiple" />
<input type="submit" name="Submit" id="Submit" value="Upload" />
}

I want to insert multiple images at a time to azure blob?

I am seleting multiple images after click upload button That selected all images upload into azure?

Give me some sample code




Responses

Posted by: kgovindarao523-21772 on: 1/3/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

Following link will help you.
http://www.dotnetcurry.com/showarticle.aspx?ID=891

Thank you,
Govind

Mandlaa, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response