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

R2: S3.PutObject non-workable against Cloudflare R2 #3955

Open
1 task done
karalabe opened this issue Feb 26, 2025 · 1 comment
Open
1 task done

R2: S3.PutObject non-workable against Cloudflare R2 #3955

karalabe opened this issue Feb 26, 2025 · 1 comment

Comments

@karalabe
Copy link

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

  • 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
Copy link
Author

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
	})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant