Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for extra headers in AppendBlock #290

Merged
merged 1 commit into from
Mar 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion storage/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,13 +825,17 @@ func (b BlobStorageClient) PutAppendBlob(container, name string, extraHeaders ma
// AppendBlock appends a block to an append blob.
//
// See https://msdn.microsoft.com/en-us/library/azure/mt427365.aspx
func (b BlobStorageClient) AppendBlock(container, name string, chunk []byte) error {
func (b BlobStorageClient) AppendBlock(container, name string, chunk []byte, extraHeaders map[string]string) error {
path := fmt.Sprintf("%s/%s", container, name)
uri := b.client.getEndpoint(blobServiceName, path, url.Values{"comp": {"appendblock"}})
headers := b.client.getStandardHeaders()
headers["x-ms-blob-type"] = string(BlobTypeAppend)
headers["Content-Length"] = fmt.Sprintf("%v", len(chunk))

for k, v := range extraHeaders {
headers[k] = v
}

resp, err := b.client.exec("PUT", uri, headers, bytes.NewReader(chunk))
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions storage/blob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ func (s *StorageBlobSuite) TestPutAppendBlobAppendBlocks(c *chk.C) {
chunk2 := []byte(randString(512))

// Append first block
c.Assert(cli.AppendBlock(cnt, blob, chunk1), chk.IsNil)
c.Assert(cli.AppendBlock(cnt, blob, chunk1, nil), chk.IsNil)

// Verify contents
out, err := cli.GetBlobRange(cnt, blob, fmt.Sprintf("%v-%v", 0, len(chunk1)-1))
Expand All @@ -694,7 +694,7 @@ func (s *StorageBlobSuite) TestPutAppendBlobAppendBlocks(c *chk.C) {
out.Close()

// Append second block
c.Assert(cli.AppendBlock(cnt, blob, chunk2), chk.IsNil)
c.Assert(cli.AppendBlock(cnt, blob, chunk2, nil), chk.IsNil)

// Verify contents
out, err = cli.GetBlobRange(cnt, blob, fmt.Sprintf("%v-%v", 0, len(chunk1)+len(chunk2)-1))
Expand Down