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
refactor GET object operations #824
Conversation
travis fail - your examples need to be updated. |
Oh, yes, thanks @poornas 👍 |
4daeec4
to
f7ddad6
Compare
api-stat.go
Outdated
@@ -81,20 +81,19 @@ func extractObjMetadata(header http.Header) http.Header { | |||
} | |||
|
|||
// StatObject verifies if object exists and you have permission to access. | |||
func (c Client) StatObject(bucketName, objectName string) (ObjectInfo, error) { | |||
func (c Client) StatObject(bucketName, objectName string, opts GetOptions) (ObjectInfo, 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.
Api.md needs to document this.
api-get-object-context.go
Outdated
func (c Client) GetObjectWithContext(ctx context.Context, bucketName, objectName string) (*Object, error) { | ||
return c.getObjectWithContext(ctx, bucketName, objectName) | ||
func (c Client) GetObjectWithContext(ctx context.Context, bucketName, objectName string, opts GetOptions) (*Object, error) { | ||
return c.getObjectWithContext(ctx, bucketName, objectName, opts) |
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.
needs documentation update for GetObjectWithContext and FGetObjectWithContext
api-get-options.go
Outdated
http.Header | ||
// GetOptions are used to specify additional headers or options | ||
// during GET requests. | ||
type GetOptions struct { |
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.
Can we rename this GetObjectOptions to be symmetric to the PutObjectOptions
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.
My plan was to rename PutObjectOptions
-> PutOptions
during encryption refactoring.
I can ask Harsha
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.
Actually it is more consistent to keep GetObjectOptions()
instead of GetOptions()
GetOptions is just too generic.
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.
Okay
@@ -72,7 +72,7 @@ func (c Client) fGetObjectWithContext(ctx context.Context, bucketName, objectNam | |||
} | |||
|
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.
needs a FGetEncryptedObject variant to match the FPutEncryptedObject.
docs/API.md
Outdated
@@ -831,7 +870,7 @@ if err != nil { | |||
} | |||
``` | |||
<a name="StatObject"></a> | |||
### StatObject(bucketName, objectName string) (ObjectInfo, error) | |||
### StatObject(bucketName, objectName string, opts GetObjectOptions) (ObjectInfo, 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.
It looks odd to pass GetObjectOptions to a HEAD call.
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.
The problem is a SSE-C call requires encryption keys - Otherwise there would be no way to get stats of an SSE-C object...
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.
Perhaps StatObject(bucketName, objectName string, opts StatObjectOptions)
--> GetObjectOptions --> StatObjectOptions
examples/s3/getobject-context.go
Outdated
@@ -47,7 +47,7 @@ func main() { | |||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute) | |||
defer cancel() | |||
|
|||
reader, err := s3Client.GetObjectWithContext(ctx, "my-bucketname", "my-objectname") | |||
reader, err := s3Client.GetObjectWithContext(ctx, "my-bucketname", "my-objectname", minio.GetObjectOptions{}) |
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.
would be good to have the example demonstrate use of the options
Looks like there is a formatting issue @aead can you fix? |
@aead, travis fails for the example. A couple of minor additions required - FGetEncryptedObject test needed for functional tests. Also believe readme.md is missing link to the example. Are we going to have a StatObjectOptions? |
We can have a simple // GetObjectOptions are used to specify additional headers or options
// during GET requests.
type GetObjectOptions struct {
headers map[string]string
UserMetadata map[string]string
Materials encrypt.Materials
}
type StatObjectOptions GetObjectOptions |
@harshavardhana
But this will lead to weird constructions like |
This would be do-able type StatObjectOptions struct {
GetObjectOptions
}
|
api-get-options.go
Outdated
func NewHeadReqHeaders() RequestHeaders { | ||
return RequestHeaders{ | ||
Header: make(http.Header), | ||
// set adds a key value pair to the options. The |
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.
comment on exported method GetObjectOptions.Set should be of the form "Set ..."
ea523f8
to
eb3e78a
Compare
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.
LGTM. Needs rebase
This change refactors get-object calls to take GetOptions. This is required to use client and server side encryption within minio-go.
This change refactors get-object calls to take GetOptions.
This is required to use client and server side encryption within
minio-go.
Updates #823