You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: object.go
    path of file: ./repos/gitlabhq/workhorse/internal/upload/destination/objectstore
    
    the code of the file until where you have to start completion: package objectstore

import (
	"context"
	"fmt"
	"io"
	"net/http"

	"gitlab.com/gitlab-org/labkit/mask"

	"gitlab.com/gitlab-org/gitlab/workhorse/internal/transport"
)

var httpClient = &http.Client{
	Transport: transport.NewRestrictedTransport(),
}

// Object represents an object on a S3 compatible Object Store service.
// It can be used as io.WriteCloser
    
func (o *Object) Upload(ctx context.Context, r io.Reader) error {
	// we should prevent pr.Close() otherwise it may shadow error set with pr.CloseWithError(err)
	req, err := http.NewRequestWithContext(ctx, http.MethodPut, o.putURL, io.NopCloser(r))

	if err != nil {
		return fmt.Errorf("PUT %q: %v", mask.URL(o.putURL), err)
	}
	req.ContentLength = o.size

	for k, v := range o.putHeaders {
		req.Header.Set(k, v)
	}

	resp, err := httpClient.Do(req)
	if err != nil {
		return fmt.Errorf("PUT request %q: %w", mask.URL(o.putURL), err)
	}
	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK {
		if o.metrics {
			objectStorageUploadRequestsInvalidStatus.Inc()
		}
		return StatusCodeError(fmt.Errorf("PUT request %v returned: %s", mask.URL(o.putURL), resp.Status))
	}

	o.etag = extractETag(resp.Header.Get("ETag"))

	return nil
}