Skip to content

Conversation

harshavardhana
Copy link
Member

This is implemented since we have already implemented
PutObjectWithMetadata() in minio-go. So following the
logic here.

This adds support to be able to specify x-amz-storage-class etc.

Fixes #482

Copy link

@hashbackup hashbackup left a comment

Choose a reason for hiding this comment

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

Took a brief look at this. At line 585, don't you mean "if not content_type"? And since there is already a default in the arg list, the only way this could happen is if fput is called with an explicit content_type=None or null string, which seems a little strange.

@harshavardhana
Copy link
Member Author

Took a brief look at this. At line 585, don't you mean "if not content_type"? And since there is already a default in the arg list, the only way this could happen is if fput is called with an explicit content_type=None or null string, which seems a little strange.

Oh yes good catch @hashbackup

@harshavardhana
Copy link
Member Author

Oh yes good catch @hashbackup

Can you validate @hashbackup this new API change?

Copy link

@hashbackup hashbackup left a comment

Choose a reason for hiding this comment

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

Looks okay to me, without running it. I'm a dumbass and can't figure out how to get a copy of the changes, sorry. Duh.

The keyword issue (case sensitive) is still a problem I think. It's not a big deal for minio devs to follow a case convention, but will likely trip up others when they start adding their own keywords / metadata. See the change I made to signer.py

Another way would be a case-insensitive dict. Not sure you want to go to the trouble, but I believe it is the most correct solution since http headers actually are case-insensitive.

@harshavardhana
Copy link
Member Author

Another way would be a case-insensitive dict. Not sure you want to go to the trouble, but I believe it is the most correct solution since http headers actually are case-insensitive.

HTTP headers are case insensitive so it doesn't matter what they are really. So you don't have to worry about it on client.

@hashbackup
Copy link

hashbackup commented Feb 24, 2017

True, it doesn't matter. But if you do this:

headers['A'] = 'xyz'
headers['a'] = 'abc'

and pass that as metadata, the minio signing procedure fails because it does a header.title() thing. That fails for the lowercase header. When I initially implemented headers, I ran into this because I used 'x-aws-storage-class' as the header name. Try it.

Update: this is a bad test case that actually works. Just use the lowercase header and it fails.

@harshavardhana
Copy link
Member Author

headers['A'] = 'xyz'
headers['a'] = 'abc'

Ah i see what you mean let me see how to avoid a scenario.

@harshavardhana
Copy link
Member Author

and pass that as metadata, the minio signing procedure fails because it does a header.title() thing. That fails for the lowercase header. When I initially implemented headers, I ran into this because I used 'x-aws-storage-class' as the header name. Try it.

Fixed it

---------START-HTTP---------
PUT /d3259f44-3cc3-49f0-aa4d-28dcaebc27f4-f HTTP/1.1
X-Amz-Content-Sha256: UNSIGNED-PAYLOAD
Content-Length: 136
X-Amz-Storage-Class: STANDARD_IA
Content-Md5: GdUHuO2I7Ong4SXepUs4Rw==
Host: minio-pytest.s3.amazonaws.com
X-Amz-Date: 20170224T203439Z
User-Agent: Minio (Linux; x86_64) minio-py/2.1.0
Authorization: AWS4-HMAC-SHA256 Credential=AKIAJY2EP7JTV2SUOH4Q/20170224/us-east-1/s3/aws4_request, SignedHeaders=content-length;content-md5;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-storage-class, Signature=bd1ca72b011e96078cb431c4d0b3d717718322d9e502f7ba0b5f8df6470ebdb4

HTTP/1.1 200
X-Amz-Id-2: Q+rs7cnD4pYbRpzPrTAiSsN7pFGR8gYDO3v+JyUXNFyI5btlCDWB9om6kzmKeUtSAYQ4TJimRZI=
X-Amz-Request-Id: 78CC40C83B527E89
Date: Fri, 24 Feb 2017 20:34:40 GMT
Etag: "19d507b8ed88ece9e0e125dea54b3847"
X-Amz-Storage-Class: STANDARD_IA
Content-Length: 0
Server: AmazonS3
---------END-HTTP---------

Works fine either way, picks one of the duplicated elements using a case insensitive dictionary helped.

This is implemented since we have already implemented
PutObjectWithMetadata() in minio-go. So following the
logic here.

This adds support to be able to specify `x-amz-storage-class` etc.

Fixes minio#482
@harshavardhana harshavardhana merged commit 649ca2d into minio:master Feb 24, 2017
@harshavardhana harshavardhana deleted the timeout branch February 24, 2017 21:02
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.

3 participants