Search code examples
azuregoazure-storage

azure storage copy: The value for one of the HTTP headers is not in the correct format


I'm using this library.

When I run:

b := container.GetBlobReference("bar")
err := b.Copy("foo", nil)

I get:

storage: service returned error: StatusCode=400, ErrorCode=InvalidHeaderValue, ErrorMessage=The value for one of the HTTP headers is not in the correct format. RequestId:66d0164b-001e-0028-2c4f-78a847000000 Time:2017-12-18T22:26:59.9585462Z, RequestInitiated=Mon, 18 Dec 2017 22:26:59 GMT, RequestId=66d0164b-001e-0028-2c4f-78a847000000, API Version=2016-05-31, QueryParameterName=, QueryParameterValue=

File "foo" does exist.

Perhaps the hint is in QueryParameterName and QueryParameterValue having no values.


Solution

  • The source to Copy must be absolute:

    destBlob := h.client.GetBlobReference(to)
    sourceBlob := h.client.GetBlobReference(from)
    err := destBlob.Copy(sourceBlob.GetURL(), nil)