0
votes

I am currently struggling to upload multiple files from the local storage to the Azure Blob Storage, I was wondering if anyone could help me, below is the code i was previously using to upload a single zip file.

    private void SaveZip(string id, string fileName, string contentType, byte[] data)
    {
        // Create a blob in container and upload image bytes to it
        var blob = this.GetContainer().GetBlobReference(fileName);

        blob.Properties.ContentType = contentType;

        // Create some metadata for this image
        var metadata = new NameValueCollection();
        metadata["Id"] = id;
        metadata["Filename"] = fileName;
    }

    SaveZip(
        Guid.NewGuid().ToString(),
        zipFile.FileName,
        zipFile.PostedFile.ContentType,
        zipFile.FileBytes);

Thanks, Sami.

5
What's the issue you're having?Greg
Sorry my question wasn't clear I have multiple files in a directory, I would like to provide the path of the directory then the code uploads all of the files.Sami
How does this upload the file to Blob storage? You never do anything with the byte array.CodeThug
I'm not sure entirely I followed a tutorial to wire up that code, it seemed to work, as I used a blob storage explorer and te files were display in the blob storage as if they had been uploadedSami

5 Answers

2
votes

It's quite straightforward with Set-AzureStorageBlobContent from azure storage powershell.

ls -File -Recurse | Set-AzureStorageBlobContent -Container upload

MSDN documentation : http://msdn.microsoft.com/en-us/library/dn408487.aspx

1
votes

I don't think there's any build-in methods you can use to upload multiple files to the BLOB. What you can do is to upload them one by one, or parallel.

1
votes

If you're just starting to work with Blob Storage, I'd encourage you to take a look at the "How to" article we've published. Specifically, the section on "How to Upload a Blob into a Container" should be helpful. Beyond that, Shaun is correct - there is no built-in support in the StorageClient library for uploading multiple files at once, but you can certainly upload them one-by-one.

0
votes

If your need is just to get it done, and not to make an app out of it, you should consider checking out Cloud Storage Studio.

0
votes

Like CodeThug said, "You never do anything with the byte array". You have to upload the data stream to the blob and you are done.