Aws-sdk-js: S3 Upload (ManagedUpload) return object

Created on 27 Jan 2017  路  4Comments  路  Source: aws/aws-sdk-js

When uploading a file as non-multipart I get the following response:
Buket : 'blah',
Etag : 'xxxxxx',
Key : "something/somefile.png",
Location : "https://some-url-address",
key : "somethings/somefile.png"

Why the multiple keys for "key". One that is uppercase and one lowercase? This isn't really all that awkward until you perform a Multipart upload which doesn't return "key" just the uppercase version.

guidance

Most helpful comment

I'd say if you're going to support the lowercase "key" in one place, you should support it everywhere until you remove it everywhere.

All 4 comments

@alloyking
The reason key appears twice is due to historical reasons. Key (uppercase) is the correct field to use (and what is documented). Under the hood, upload calls putObject or does a multi-part upload. Only one of those operations actually returns the key back in the response, so the SDK filled in the other one. Since we found out users were already relying on existing behavior, we documented just the one Key, but left both in to avoid breaking those users until we do a major version bump.

I'd say if you're going to support the lowercase "key" in one place, you should support it everywhere until you remove it everywhere.

In my case, I handle the response to get the key by { key }, unfortunately I used the lower case. In most of the case the it works, but for large files it failed. Then I figured out for large file, it only has field upper case "Key".

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings