Windows Azure: Creating a subdirectories inside the blob
Posted
by veda
on Stack Overflow
See other posts from Stack Overflow
or by veda
Published on 2010-04-11T18:35:45Z
Indexed on
2010/04/11
18:43 UTC
Read the original article
Hit count: 270
I wanted to create some subdirectories inside my blob. But it is not working out well
Here is my code
protected void ButUpload_click(object sender, EventArgs e)
{
// store upladed file as a blob storage
if (uplFileUpload.HasFile)
{
name = uplFileUpload.FileName;
// get refernce to the cloud blob container
CloudBlobContainer blobContainer = cloudBlobClient.GetContainerReference("documents");
if (textbox.Text != "")
{
name = textbox.Text + "/" + name;
}
// set the name for the uploading files
string UploadDocName = name;
// get the blob reference and set the metadata properties
CloudBlockBlob blob = blobContainer.GetBlockBlobReference(UploadDocName);
blob.Metadata["FILETYPE"] = "text";
blob.Properties.ContentType = uplFileUpload.PostedFile.ContentType;
// upload the blob to the storage
blob.UploadFromStream(uplFileUpload.FileContent);
}
}
What I did is that, If I have to create a sub directory, I will enter the name of the sub directory in the textbox.
for example, if I need to create a file named "test.txt" inside the sub directory "files" Then, my textbox.text = files and uplFileUpload.FileName = test.txt
Now I will concatenate them and upload to the blob.. But it is not working well.. I am getting just https://test.core.windows.net/documents/files/
I am not getting the entire thing I was expecting https://test.core.windows.net/documents/files/test.txt
What am I doing wrong... How to create sub directories inside the blob.
© Stack Overflow or respective owner