This is mostly an issue with Amazon's API rather than your code. Uploading a file to Amazon requires the Content-Length
header to be set. In your stream example, the length is unknown so Amazon is just dropping the connection. In your second example, request
knows the length of the buffer and sets the Content-Length
for you.
If you are streaming because the file is huge and loading it all into RAM is hard, then you will need to use Amazon's multi-part uploading APIs. If you are streaming but the file is small, then I'd probably stick with the readFile
method.