Code Monkey home page Code Monkey logo

Comments (12)

domenic avatar domenic commented on August 17, 2024

You need to send Content-Length or use putFile to get it automatically. Without Content-Length Node automatically sets some weird header (Transfer-Encoding: chunked, maybe?) which Amazon rejects.

from knox.

rauchg avatar rauchg commented on August 17, 2024

@domenic let's put a warning in there if Content-Length is not set

from knox.

rauchg avatar rauchg commented on August 17, 2024

Unfortunately we need to take it upon ourselves to improve the error reporting at the client layer, because Amazon does a terrible job with that.

from knox.

TooTallNate avatar TooTallNate commented on August 17, 2024

We can explicitly disable chunked encoding in node by forcing Connection: close. Getting the "Content-Length" in my case would require Buffering a HTTP request in memory, which I want to avoid.

from knox.

rauchg avatar rauchg commented on August 17, 2024

So in the absence of Content-Length in the request we should do that then.

from knox.

rauchg avatar rauchg commented on August 17, 2024

If S3 doesn't support that though, we probably just need to stat the file @TooTallNate and send it along as Content-Length

from knox.

TooTallNate avatar TooTallNate commented on August 17, 2024

Forcing "identity" transfer encoding makes the 501 turn into a 403, but it still doesn't work...

var headers = {};
headers['content-type'] = 'image/jpeg';
headers['transfer-encoding'] = 'identity';
headers['connection'] = 'close';

Gives back XML like:

<?xml version="1.0" encoding="UTF-8"?>
<Error>
  <Code>SignatureDoesNotMatch</Code>
  <Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
  <StringToSignBytes>50 55 54 0a 0a 69 6d 61 67 65 2f 6a 70 65 67 0a 46 72 69 2c 20 32 31 20 53 65 70 20 32 30 31 32 20 32 31 3a 35 31 3a 31 32 20 47 4d 54 0a 78 2d 61 6d 7a 2d 61 63 6c 3a 70 75 62 6c 69 63 2d 72 65 61 64 0a 2f 63 6c 6f 75 64 75 70 2d 66 69 6c 60 73 2f 6e 61 74 65 2d 61 76 61 74 61 72 2e 6a 70 67</StringToSignBytes>
  <RequestId>D66D3C6DBC680FFF</RequestId>
  <HostId>1L58FhSdqqis1t5xH87Z5cBS/Rvwn2IVXq6CLa/Xa7E3hSkEAqbEw+AtnmX0e/xy</HostId>
  <SignatureProvided>cHw1NkjS/vzwuU6haCE+Rzj2mMI=</SignatureProvided>
<StringToSign>PUT

image/jpeg
Fri, 21 Sep 2012 21:51:12 GMT
x-amz-acl:public-read
/cloudup-files/nate-avatar.jpg</StringToSign>
  <AWSAccessKeyId>...</AWSAccessKeyId>
</Error>

from knox.

domenic avatar domenic commented on August 17, 2024

Notably stat'ing the file to get its Content-Length is exactly what putFile does.

from knox.

domenic avatar domenic commented on August 17, 2024

Oh interesting, I wonder if this uncovers a deficiency in the signing algorithm or if Amazon is just giving inaccurate error messages. Hmm!

from knox.

TooTallNate avatar TooTallNate commented on August 17, 2024

It would be killer if knox supported a multipart upload handling API (or did this behind the scenes!) http://stackoverflow.com/questions/8653146/can-i-stream-a-file-upload-to-s3-without-a-content-length-header

from knox.

domenic avatar domenic commented on August 17, 2024

@TooTallNate pull request welcome!!

from knox.

domenic avatar domenic commented on August 17, 2024

Added early error in 41cc7a6 which will be released shortly as 0.3.1.

from knox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.