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