Allow setting custom upload limits - #2299
Conversation
Adds to client configuration:
```
// UploadLimits overrides the upload limits the client enforces before sending
// a request. The defaults are the limits Amazon S3 imposes; only raise them
// when the remote endpoint is known to accept the larger values.
//
// A zero field means "use the default", so the zero UploadLimits behaves
// exactly like Amazon S3.
type UploadLimits struct {
// MinPartSize is the smallest size allowed for a part that is not the
// last part of a multipart upload. Defaults to 5 MiB.
MinPartSize int64
// MaxPartSize is the largest size allowed for a single part.
// Defaults to 5 GiB.
MaxPartSize int64
// MaxPartsCount is the maximum number of parts in a single multipart
// upload. Together with MaxPartSize this caps the object size the client
// is willing to upload. Defaults to 10000.
MaxPartsCount int64
// MaxSinglePutObjectSize is the largest object the remote accepts in a
// single PUT. Defaults to 5 GiB.
MaxSinglePutObjectSize int64
}
```
📝 WalkthroughWalkthroughThe client now supports configurable upload limits through ChangesConfigurable upload limits
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: 🟡 Moderate · up to The PR adds configurable upload limits, but the current implementation can reject valid uploads, generate multipart parts that violate configured limits, allow appended objects to exceed those limits, and exceed MaxPartSize in an integer-rounding edge case. These correctness issues should be fixed before merging. Sequence Diagram(s)sequenceDiagram
participant Options
participant privateNew
participant Client
participant UploadLimits
participant PutObject
Options->>privateNew: provide UploadLimits
privateNew->>UploadLimits: validate limits
privateNew->>Client: store validated limits
PutObject->>Client: resolve object and part limits
Client->>UploadLimits: read configured or default values
UploadLimits-->>Client: return validation and part-size results
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
✅ Action performedComments resolved and changes approved. |
| // Upload limits enforced before sending a request. Always read through | ||
| // its accessors, which resolve zero fields to the S3 defaults. |
There was a problem hiding this comment.
| // Upload limits enforced before sending a request. Always read through | |
| // its accessors, which resolve zero fields to the S3 defaults. | |
| // Upload limits enforced before sending a request. Read through its | |
| // accessors, which resolve zero fields to the S3 defaults — except | |
| // MaxSinglePutObjectSize on the PutObject path, where an unset field | |
| // deliberately means "no limit" (see api-put-object.go). |
Adds to client configuration:
Summary by CodeRabbit
New Features
Bug Fixes
Tests