azure-sdk-for-go: GetBlob for blob names contain spaces fail

Hi.

I confused. I try to execute this code:

    basicClient, _ := storage.NewBasicClient(accountName, accountKey)
    storageClient := basicClient.GetBlobService()

    listOfBlobs, err := storageClient.ListBlobs("user1", storage.ListBlobsParameters{})

    if err != nil {  // PASS OK
        panic(err) 
    }

    for idx, blob := range listOfBlobs.Blobs {
        blobEntity, err := storageClient.GetBlob("user1", blob.Name);

        if err != nil { // GET ERROR
            panic(err) 
        } 
    }

Invokes two API methods the ListBlobs and GetBlob. ListBlobs’s execution result is OK, but when I execute GetBlob, I get error:

storage: service returned error: StatusCode=403, ErrorCode=AuthenticationFailed, ErrorMessage=Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:0a99ee7e-0001-0117-222e-d584a8000000

Could you help me, please? Thank’s.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

Also having this problem - really need a fix for it. I am passing in the name that Azure gives me:

func TestNamesWithSpaces(t *testing.T) {
    is := is.New(t)
    basicClient, err := storage.NewBasicClient(azureaccount, azurekey)
    is.NoErr(err)
    blobService := basicClient.GetBlobService()
    containersResp, err := blobService.ListContainers(storage.ListContainersParameters{
        MaxResults: 10,
        Prefix:     "",
    })
    is.NoErr(err)
    container := containersResp.Containers[1]
    blobs, err := blobService.ListBlobs(container.Name, storage.ListBlobsParameters{
        Prefix:     "",
        MaxResults: 10,
    })
    is.NoErr(err)
    blob := blobs.Blobs[0]
    log.Println("blob name:", blob.Name)
    props, err := blobService.GetBlobProperties(container.Name, blob.Name)
    is.NoErr(err)
    log.Println("props", props)
}

NOTE: the above code uses github.com/cheekybits/is for testing.