9

I know that we can upload files to azure blob storage using below:

        CloudBlockBlob cloudBlockBlob = fileContainer.GetBlockBlobReference(fileName);
        await cloudBlockBlob.UploadFromFileAsync(fileFullPath);

I already created some folders in the container. I tried a few time but the files always uploaded outside the folder.

How do we upload the files into a specific folder in the blob storage?

0

2 Answers 2

9

I guess you have to get the right reference first ( you need to include the fullpath of the file in the GetBlockBlobReference) as in :

 CloudBlockBlob cloudBlockBlob = fileContainer.GetBlockBlobReference($"yourfoldername/{fileName}");

One important thing is you DON'T need to create folder, it will automatically create it for you based on your path in the GetBlockBlobReference.

Sign up to request clarification or add additional context in comments.

Comments

9

Actually there aren't real folders in Azure Blob Storage, it's just a virtual concept. In other words, Azure Blob Storage only has simple 2-level "container - blob" structure, the so-called "folders" are just prefixes of existing blob names.

For example, if there is a blob named a/b/c.jpg. The a and b are virtual folder names, you can't directly create or delete them, they exist there just because of blob a/b/c.jpg.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.