0

I am in a situation where i have 1000's of blobs in azure storage which are pictures with url having space in it which is a problem. so as a measure we want to update blob uri and remove spaces in each of them which has one. I know how to get blobs or would figure out but not able to understand how can i update the uri once i get a blob here is my current code to get blobs.

        CloudBlobContainer container = GetContainerReference('containername');
        var blobs=container.ListBlobs().Select(p=>p.Uri.ToString().Contains(' '));
        foreach (CloudBlob item in blobs)
        {

        }
2
  • Assuming it can be done, wouldn't just removing the space from the blob's name (or URI) make your blob inaccessible? The blob stored in blob storage has a space in its name/URI? Commented Mar 15, 2013 at 6:51
  • uri.i agree. probably deleting and creating copy of it is the solution.. Commented Mar 15, 2013 at 9:43

1 Answer 1

3

The Windows Azure BlobStorage API does not provide a method that allows you to change a blob's URI directly. However you still can copy the blob to a new one which has no spaces in its URI and then delete the old one.

CloudBlobContainer container = GetContainerReference('containername');
var blobs = container.ListBlobs().Select(p => p.Uri.ToString().Contains(' '));
foreach (CloudBlob oldBlob in blobs)
{
    var newBlobName = oldBlob.Name.Replace(" ", String.Empty);
    var newBlob = container.GetBlobReference(newBlobName);
    newBlob.CopyFromBlob(oldBlob);

    oldBlob.Delete();
}
Sign up to request clarification or add additional context in comments.

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.