Skip to content

Commit

Permalink
Merge pull request #3042 from buildkite/fix-s3-multipart-headers
Browse files Browse the repository at this point in the history
Fix request headers for multipart
  • Loading branch information
DrJosh9000 authored Oct 17, 2024
2 parents 633847d + 5f390d9 commit 066c69c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/artifact/bk_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,12 @@ func (u *bkMultipartUpload) DoWork(ctx context.Context) (*api.ArtifactPartETag,
return nil, err
}

// Content-Range is mostly for debugging purposes.
// Note thatContent-Ranges are 0-indexed and inclusive
// example: Content-Range: bytes 200-1000/67589
req.Header.Set("Content-Range", fmt.Sprintf("bytes %d-%d/%d", u.offset, u.offset+u.size-1, u.artifact.FileSize))
// Content-Range would be useful for debugging purposes, but S3 will reject
// the request.
// Content-Length is needed to avoid Go adding Transfer-Encoding: chunked
// which would also cause S3 to reject the request (plus we know the part
// length in advance).
req.ContentLength = u.size
req.Header.Set("Content-Type", u.artifact.ContentType)

client := agenthttp.NewClient(
Expand Down

0 comments on commit 066c69c

Please sign in to comment.