Uppy: [aws-s3] Uploading with put throws an error (due to missing Content-Type header in response)

Created on 29 Dec 2019  路  6Comments  路  Source: transloadit/uppy

Hi!

As mentioned in the title: the PUT response from aws will return no "Content-Type" header. The following example shows the headers return by a simple PUT request to S3.

HTTP/1.1 200 OK
x-amz-id-2: q4jaFwYFbwWjQZzI3jHoGygUWOdGwaMPfTVAPnTVvseJQ7KjWfRylI/ho0aIlP6V7CctJQrkbq8=
x-amz-request-id: 09DC93B9A15AD167
Date: Sun, 29 Dec 2019 11:14:59 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: PUT, POST, DELETE
Vary: Origin, Access-Control-Request-Headers, Access-Control-Request-Method
ETag: "8346e97a75f3c6278c9e6a46f5374c1b"
Content-Length: 0
Server: AmazonS3

This response leads to the following error:

Uncaught TypeError: Cannot read property 'replace' of null
    at isXml (index.js:32)
    at Object.getResponseData (index.js:246)
    at XMLHttpRequest.<anonymous> (index.js:291)

In the isXml() function it is expected that the header is set.

Does it make sense to just return false in case the Content-Type is not set?

Bug Triage

Most helpful comment

Great that this issue has been fixed! Do we know when it will be in the latest release on npm?

All 6 comments

Facing the same issue.

Also experiencing this. Did AWS change their response headers suddenly? It still works fine for me in production oddly, I'm only getting this error in development...

Facing same issue

It is possible that AWS did change something but it shouldn't be expected that this header is set, because:

  1. It is not required in the HTTP standard to be set
  2. There is no indication of this header in the AWS documentation

Great that this issue has been fixed! Do we know when it will be in the latest release on npm?

@rmaspero It looks like it's already been released on NPM: "@uppy/aws-s3": "^1.4.1". I upgraded my package version to this and it's fixed it. Thanks again @roenschg!

See Changelog here: https://github.com/transloadit/uppy/blob/master/CHANGELOG.md#180

Was this page helpful?
0 / 5 - 0 ratings