cloudflare-go icon indicating copy to clipboard operation
cloudflare-go copied to clipboard

R2: S3.PutObject non-workable against Cloudflare R2

Open karalabe opened this issue 1 year ago • 1 comments

Confirm this is a Go library issue and not an underlying Cloudflare API issue

  • [x] This is an issue with the Go library

Describe the bug

This is a bit of a weird bug report because I'm not sure who to blame.

If I try to upload a larger object with github.com/aws/aws-sdk-go-v2/service/s3.PutObject. Using v1.72.3 works perfectly. Anything newer and it just loops indefinitely, never finishing the upload.

There is a a compatibility note in https://developers.cloudflare.com/r2/examples/aws/aws-sdk-go/, it does not fix it. Any version newer than v1.72.3 chokes on R2.

To Reproduce

Call s3.PutObject with anything larger than a few megabytes using v1.77.1

Code snippets


OS

macOS

Go version

Go 1.24.0

Library version

github.com/cloudflare/cloudflare-go/v4 v4.1.0

karalabe avatar Feb 26 '25 20:02 karalabe

Figured it out-ish. The compatibility note is wrong:

config.WithRequestChecksumCalculation(0)
config.WithResponseChecksumValidation(0)

The first call here is a noop:

// WithRequestChecksumCalculation is a helper function to construct functional options
// that sets RequestChecksumCalculation on config's LoadOptions
func WithRequestChecksumCalculation(c aws.RequestChecksumCalculation) LoadOptionsFunc {
	return func(o *LoadOptions) error {
		if c > 0 {
			o.RequestChecksumCalculation = c
		}
		return nil
	}
}

You need to manually force it through:

PutObject(ctx, params, func(opts *s3.Options) {
		opts.RequestChecksumCalculation = 0
		opts.ResponseChecksumValidation = 0
	})

karalabe avatar Feb 26 '25 21:02 karalabe

thanks for the notes here. closing this out but let me know if you have anything else.

jacobbednarz avatar Mar 31 '25 21:03 jacobbednarz