diff --git a/s3/backend.go b/s3/backend.go index 9f6c8beef..e78ab9cfd 100644 --- a/s3/backend.go +++ b/s3/backend.go @@ -401,7 +401,7 @@ func (s *s3) CreateMultipartUpload(ctx context.Context, bucket, key string, meta } func (s *s3) UploadPart(ctx context.Context, bucket, object string, id gofakes3.UploadID, partNumber int, contentLength int64, input io.Reader) (*gofakes3.UploadPartResult, error) { - res, err := s.w.UploadMultipartUploadPart(ctx, input, bucket, object, string(id), partNumber, api.UploadMultipartUploadPartOptions{ + res, err := s.w.UploadMultipartUploadPart(ctx, input, bucket, object, string(id), partNumber, contentLength, api.UploadMultipartUploadPartOptions{ DisablePreshardingEncryption: true, }) if err != nil { diff --git a/s3/s3.go b/s3/s3.go index dc7ac664b..23ecc06c5 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -49,7 +49,7 @@ type bus interface { type worker interface { GetObject(ctx context.Context, bucket, path string, opts api.DownloadObjectOptions) (*api.GetObjectResponse, error) UploadObject(ctx context.Context, r io.Reader, bucket, path string, opts api.UploadObjectOptions) (*api.UploadObjectResponse, error) - UploadMultipartUploadPart(ctx context.Context, r io.Reader, bucket, path, uploadID string, partNumber int, opts api.UploadMultipartUploadPartOptions) (*api.UploadMultipartUploadPartResponse, error) + UploadMultipartUploadPart(ctx context.Context, r io.Reader, bucket, path, uploadID string, partNumber int, contentLength int64, opts api.UploadMultipartUploadPartOptions) (*api.UploadMultipartUploadPartResponse, error) } func (l *gofakes3Logger) Print(level gofakes3.LogLevel, v ...interface{}) { diff --git a/worker/client/client.go b/worker/client/client.go index 048ce225c..fcb8f261f 100644 --- a/worker/client/client.go +++ b/worker/client/client.go @@ -174,7 +174,7 @@ func (c *Client) State() (state api.WorkerStateResponse, err error) { } // UploadMultipartUploadPart uploads part of the data for a multipart upload. -func (c *Client) UploadMultipartUploadPart(ctx context.Context, r io.Reader, bucket, path, uploadID string, partNumber int, opts api.UploadMultipartUploadPartOptions) (*api.UploadMultipartUploadPartResponse, error) { +func (c *Client) UploadMultipartUploadPart(ctx context.Context, r io.Reader, bucket, path, uploadID string, partNumber int, contentLength int64, opts api.UploadMultipartUploadPartOptions) (*api.UploadMultipartUploadPartResponse, error) { path = api.ObjectPathEscape(path) c.c.Custom("PUT", fmt.Sprintf("/multipart/%s", path), []byte{}, nil) @@ -194,6 +194,7 @@ func (c *Client) UploadMultipartUploadPart(ctx context.Context, r io.Reader, buc panic(err) } req.SetBasicAuth("", c.c.WithContext(ctx).Password) + req.Header.Add("X-Content-Length", fmt.Sprintf("%d", contentLength)) resp, err := http.DefaultClient.Do(req) if err != nil { return nil, err