Aws-sdk-js: S3 putObject and uploadPart missing ETag in response

Created on 15 Nov 2013  路  8Comments  路  Source: aws/aws-sdk-js

version: AWS SDK for JavaScript v2.0.0-rc1

Hi there,
I am getting a success callback from s3.uploadPart and s3.putObject however the response does not contain the ETag.
I can see in the browser console that the Put Http response headers do indeed contain the Etag, however it does not make it into the aws sdk callback.

eg the put generated by s3.uploadPart has the following in the response:
data
Object { RequestId=undefined}

RequestId
undefined

error
null
and here is the generated Http PUT request response headers showing the Etag

https://mybucket.s3-ap-southeast-2.amazonaws.com/6dea067e-895f-4b8b-bf61-a1aab9493f6b?partNumber=1&uploadId=CSiSxOQQ7fxssXYIAnnoy8YVZz2EZCrXNMx0hDL5HaDpfgMlubTljlh6gwIbx7SK2B8OLhN6XdwbFzYYU3u6yf.78fBg4LiN9h2AuvKzMD8WUmx0OWkwQk5HBe.DbT_viidB35sRXGekuQlYnDhSSw--

Response Headers
Access-Control-Allow-Cred... true
Access-Control-Allow-Meth... GET, PUT, POST, DELETE
Access-Control-Allow-Orig... https://mymachine
Content-Length 0
Date Fri, 15 Nov 2013 04:00:29 GMT
Etag "0acd6295ee14e480a20c6adee883ff42"
Server AmazonS3
Vary Origin, Access-Control-Request-Headers, Access-Control-Request-Method
x-amz-id-2 jIKw3XnK6EYO33fp6bu2dqVUsqmasTG2YExWsyvCKH7a34bY1MuDO3Bcl3LqW/gq
x-amz-request-id C59C54EB936BA018

cheers

Most helpful comment

The ETag is sent back as a header, and S3 requires that you configure all exposed response headers via the CORS configuration. You can do this by adding

<ExposeHeader>ETag</ExposeHeader>

In your CORS config. You would do this for any other header elements you want to access via CORS.

Does that help?

All 8 comments

The ETag is sent back as a header, and S3 requires that you configure all exposed response headers via the CORS configuration. You can do this by adding

<ExposeHeader>ETag</ExposeHeader>

In your CORS config. You would do this for any other header elements you want to access via CORS.

Does that help?

Thank you that was it.
I also added an ExposeHeader to the CORS config for the x-amz-request-id parameter to get the RequestId populated in the response.

@lsegal Thanks for the help. BTW I wanted to know why we should set <ExposeHeader>ETag</ExposeHeader> ? What's purpose of Etag?

@meetzaveri I'm guessing it's so the multiple parts being uploaded can read the ETag header and know which S3 object they're going to be concatenated to.

@ffxsam Good to know!

thank you @lsegal

I've updated my CORS headers as shown in the docs, but I still get an error message with large files. Small files (non-multipart) upload without a problem.

My CORS is straight from the updated docs:

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>HEAD</AllowedMethod>
    <AllowedMethod>GET</AllowedMethod>
    <AllowedMethod>PUT</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <AllowedMethod>DELETE</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <ExposeHeader>x-amz-server-side-encryption</ExposeHeader>
    <ExposeHeader>x-amz-request-id</ExposeHeader>
    <ExposeHeader>x-amz-id-2</ExposeHeader>
    <ExposeHeader>ETag</ExposeHeader>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>

My js error:

ETagMissing: No access to ETag property on response. Check CORS configuration to expose ETag header.
    at Response.eval (webpack-internal:///./node_modules/aws-sdk/lib/s3/managed_upload.js:570:30)
    at Request.eval (webpack-internal:///./node_modules/aws-sdk/lib/request.js:367:18)
    at Request.callListeners (webpack-internal:///./node_modules/aws-sdk/lib/sequential_executor.js:115:20)
    at Request.emit (webpack-internal:///./node_modules/aws-sdk/lib/sequential_executor.js:82:10)
    at Request.emit (webpack-internal:///./node_modules/aws-sdk/lib/request.js:697:14)
    at Request.transition (webpack-internal:///./node_modules/aws-sdk/lib/request.js:30:10)
    at AcceptorStateMachine.runTo (webpack-internal:///./node_modules/aws-sdk/lib/state_machine.js:16:12)
    at eval (webpack-internal:///./node_modules/aws-sdk/lib/state_machine.js:27:10)
    at Request.eval (webpack-internal:///./node_modules/aws-sdk/lib/request.js:46:9)
    at Request.eval (webpack-internal:///./node_modules/aws-sdk/lib/request.js:699:12)
    at Request.callListeners (webpack-internal:///./node_modules/aws-sdk/lib/sequential_executor.js:127:18)
    at Request.emit (webpack-internal:///./node_modules/aws-sdk/lib/sequential_executor.js:82:10)
    at Request.emit (webpack-internal:///./node_modules/aws-sdk/lib/request.js:697:14)
    at Request.transition (webpack-internal:///./node_modules/aws-sdk/lib/request.js:30:10)
    at AcceptorStateMachine.runTo (webpack-internal:///./node_modules/aws-sdk/lib/state_machine.js:16:12)
    at eval (webpack-internal:///./node_modules/aws-sdk/lib/state_machine.js:27:10)
    at Request.eval (webpack-internal:///./node_modules/aws-sdk/lib/request.js:46:9)
    at Request.eval (webpack-internal:///./node_modules/aws-sdk/lib/request.js:699:12)
    at Request.callListeners (webpack-internal:///./node_modules/aws-sdk/lib/sequential_executor.js:127:18)
    at Request.emit (webpack-internal:///./node_modules/aws-sdk/lib/sequential_executor.js:82:10)
    at Request.emit (webpack-internal:///./node_modules/aws-sdk/lib/request.js:697:14)
    at Request.transition (webpack-internal:///./node_modules/aws-sdk/lib/request.js:30:10)
    at AcceptorStateMachine.runTo (webpack-internal:///./node_modules/aws-sdk/lib/state_machine.js:16:12)
    at eval (webpack-internal:///./node_modules/aws-sdk/lib/state_machine.js:27:10)
    at Request.eval (webpack-internal:///./node_modules/aws-sdk/lib/request.js:46:9)
    at Request.eval (webpack-internal:///./node_modules/aws-sdk/lib/request.js:699:12)
    at Request.callListeners (webpack-internal:///./node_modules/aws-sdk/lib/sequential_executor.js:127:18)
    at Request.emit (webpack-internal:///./node_modules/aws-sdk/lib/sequential_executor.js:82:10)
    at Request.emit (webpack-internal:///./node_modules/aws-sdk/lib/request.js:697:14)
    at Request.transition (webpack-internal:///./node_modules/aws-sdk/lib/request.js:30:10)
    at AcceptorStateMachine.runTo (webpack-internal:///./node_modules/aws-sdk/lib/state_machine.js:16:12)
    at eval (webpack-internal:///./node_modules/aws-sdk/lib/state_machine.js:27:10)
    at Request.eval (webpack-internal:///./node_modules/aws-sdk/lib/request.js:46:9)
    at Request.eval (webpack-internal:///./node_modules/aws-sdk/lib/request.js:699:12)
    at Request.callListeners (webpack-internal:///./node_modules/aws-sdk/lib/sequential_executor.js:127:18)
    at callNextListener (webpack-internal:///./node_modules/aws-sdk/lib/sequential_executor.js:102:12)
    at EventEmitter.onEnd (webpack-internal:///./node_modules/aws-sdk/lib/event_listeners.js:302:13)
    at EventEmitter.emit (webpack-internal:///./node_modules/node-libs-browser/node_modules/events/events.js:136:5)
    at features.constructor.finishRequest (webpack-internal:///./node_modules/aws-sdk/lib/http/xhr.js:130:13)
    at XMLHttpRequest.eval (webpack-internal:///./node_modules/aws-sdk/lib/http/xhr.js:41:14)

I may be missing something obvious. If any of you have suggestions they would be much appreciated.

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