-
Notifications
You must be signed in to change notification settings - Fork 329
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 metadata to get, fget and get_partial methods #522
Conversation
minio/api.py
Outdated
@@ -698,6 +698,8 @@ def fget_object(self, bucket_name, object_name, file_path): | |||
:param bucket_name: Bucket to read object from. | |||
:param object_name: Name of the object to read. | |||
:param file_path: Local file path to save the object. | |||
:param metadata: Any additional metadata to be uploaded along |
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.
Are you sure this is what you want to do? GET doesn't upload any object in-fact it downloads the object. How does adding another parameter to fget_object help here? .
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.
As example I can provide a case, when you using SSE-C and want to provide custom headers to get decrypted file from S3:
key = b'32byteslongsecretkeymustprovided'
encryption_key = base64.b64encode(key).decode()
encryption_key_md5 = base64.b64encode(hashlib.md5(key).digest()).decode()
minio = Minio('s3.amazonaws.com', access_key=AWSAccessKeyId, secret_key=AWSSecretKey)
obj = minio.get_object(S3_BUCKET, 'test_crypt.txt', metadata={
'x-amz-server-side-encryption-customer-algorithm': 'AES256',
'x-amz-server-side-encryption-customer-key': encryption_key,
'x-amz-server-side-encryption-customer-key-MD5': encryption_key_md5
})
print(obj.read())
minio.put_object(S3_BUCKET, 'test_crypt1.txt', content, content.getbuffer().nbytes,
metadata={
'x-amz-server-side-encryption-customer-algorithm': 'AES256',
'x-amz-server-side-encryption-customer-key': encryption_key,
'x-amz-server-side-encryption-customer-key-MD5': encryption_key_md5
})
obj = minio.get_object(S3_BUCKET, 'test_crypt1.txt', metadata={
'x-amz-server-side-encryption-customer-algorithm': 'AES256',
'x-amz-server-side-encryption-customer-key': encryption_key,
'x-amz-server-side-encryption-customer-key-MD5': encryption_key_md5
})
print(obj.read())
Then perhaps you need to update the comment.. to reflect the right purpose here. Rather than saying With this we can also support now 'If-Match', 'If-Modified-Since' etc. Additionally it would be cleaner to get a full example added as well to |
@harshavardhana I'm agreed, that P. S. Also I saw that CI was failed, I'm looking what's happened now |
Tests fixed and documentation is updated with example of usage |
minio/api.py
Outdated
@@ -698,8 +698,7 @@ def fget_object(self, bucket_name, object_name, file_path, metadata=None): | |||
:param bucket_name: Bucket to read object from. | |||
:param object_name: Name of the object to read. | |||
:param file_path: Local file path to save the object. | |||
:param metadata: Any additional metadata to be uploaded along | |||
with your GET request. | |||
:param metadata: Any additional metadata to be added to GET request's headers. |
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.
IMHO we should keep it as request headers, in put_object it is meant to be saved with the object. Here it is meant to be queried.. so it is better to named request_headers or req_headers makes the code more readable.
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.
Ok, agreed, I will rename it right now :)
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.
Tested with If-Match, If-Modified-Since.. LGTM
@harshavardhana So, as far as you approved this PR, when I could expect this on the master branch? I want to use it in my project :) |
Regard to this issue: #521 I want to add support for additional headers in
get
methods.