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

Add support for object upload options #164

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fpetkovski
Copy link
Contributor

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.

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Verification

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]>
Copy link
Member

@bwplotka bwplotka left a 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not simpler?

Suggested change
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)
Copy link
Member

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

Suggested change
type ObjectUploadOption func(f *UploadObjectParams)
type UploadOption func(f *uploadOptions)

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

Successfully merging this pull request may close these issues.

2 participants