-
Notifications
You must be signed in to change notification settings - Fork 86
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
Add support for object upload options #164
base: main
Are you sure you want to change the base?
Conversation
I would like to be able to set the content type on uploaded objects since some providers cannot show a preview if the content type is missing. To facilitate this, I've extended the UploadObject method to accept a variable list of options. The only introduction option is the content type, but it is extensible for other options. Signed-off-by: Filip Petkovski <[email protected]>
Signed-off-by: Filip Petkovski <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits, otherwise LGTM!
@@ -62,7 +62,7 @@ type Bucket interface { | |||
|
|||
// Upload the contents of the reader as an object into the bucket. | |||
// Upload should be idempotent. | |||
Upload(ctx context.Context, name string, r io.Reader) error | |||
Upload(ctx context.Context, name string, r io.Reader, opts ...ObjectUploadOption) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not simpler?
Upload(ctx context.Context, name string, r io.Reader, opts ...ObjectUploadOption) error | |
Upload(ctx context.Context, name string, r io.Reader, opts ...UploadOption) error |
ContentType string | ||
} | ||
|
||
type ObjectUploadOption func(f *UploadObjectParams) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can simplify (no need for params to be public struct):
type ObjectUploadOption func(f *UploadObjectParams) | |
type UploadOption func(f *uploadOptions) |
I would like to be able to set the content type on uploaded objects since some providers cannot show a preview if the content type is missing.
To facilitate this, I've extended the UploadObject method to accept a variable list of options. The only introduction option is the content type, but it is extensible for other options.
Changes
Verification