Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Cant putStream #18

Closed
japrescott opened this Issue · 5 comments

2 participants

@japrescott

Hello SaltwaterC
1. you are awesome! but you knew that already..
2. aws2js is awesome, but you knew that as well..
3. I have a little problematic situation, that I cant track down, why this isn't working. Maybe you could look into the Problem on stackoverflow; http://stackoverflow.com/questions/9087619/cant-save-read-stream-to-amazon-s3-using-aws2js

@SaltwaterC
Owner

Thanks.

Since you stated that you were struggling for 4 days, I can safely assume that you used 0.6.3 or less since 0.6.4 was released Monday. Please update aws2js to v0.6.5 and try again. If the issue persists, I am going to need more info from your setup.

Thing is that aws2js v0.6.4+ changed the way how PUT requests work when the Stream request body handler is involved. I didn't mention it into the CHANGELOG as I forgot about it, but it is there.

Speaking in code, in v0.6.3< it was handled like this:

if (body instanceof Stream) {
    body.pipe(request);
    return;
}

Since 0.6.4 it is handled like this:

if (body instanceof Stream) { // some requests don't like body.pipe(request). bummer.
    body.on('data', function (chunk) {
        if ( ! aborted) {
            request.write(chunk);
        }
    });
    body.on('end', function () {
        if ( ! aborted) {
            request.end();
        }
    });
    return;
}

The commend says it all. For small requests body.pipe() proved to be OK, therefore the s3-put-stream test didn't caught it, but when I implemented the S3 Multipart Upload API things started to break for the s3.put() method as it works with requests that usually have at least 5 MiB in size.

@japrescott

Thank you for looking into this so fast! I saw you made a new commit, but haven't had the change to test it with node 0.6.9. I'll let u know, as soon as I get a chance to test it.

@SaltwaterC
Owner

I was talking about the aws2js versions. About node.js: v0.6.9 is broken. Use v0.6.8. The whole story is in #15.

LE: aws2js v0.6.5 is stable (or, at least it passes all the unit tests).

@japrescott

Thanks for rectifying that. I tested my setup now with Node 0.6.5 (didn't have time to recompile 0.6.8) and npm tells me, that aws2js@0.6.4 is beeing used. I'm using the code, as I described it in my stackoverflow post and; IT WORKS! HURRAY :) putStream saves the file, everything good, content there, file viewable.
Only thing I did notice was, that the success msg of aws had a 'content-length' (see; the single quotes) set to 0, even thou it saved a ~9000bytes file. But that very well could be AWS beeing AWS.

@SaltwaterC
Owner

That Content-Lenght header is for the response body of the PUT operation. See the PUT Object examples of the S3 REST API docs.

@SaltwaterC SaltwaterC closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.