Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How is putFile() supposed to work? #313

Open
spazmodius opened this issue Oct 14, 2016 · 2 comments
Open

How is putFile() supposed to work? #313

spazmodius opened this issue Oct 14, 2016 · 2 comments

Comments

@spazmodius
Copy link

OK, the more I read about issues with .putFile(), and documentation or lack thereof, and "do something with res or at least call res.resume()", the less sure I become that I actually know what this method does.

Let me describe what I thought I thought, and you who know better please correct me...

I believed that calling client.putFile(localFilename, s3Filename, cb) would go through the motions of POSTing (streaming) the contents of my file to S3 using their protocol. When this is done, or has failed, it will call my cb. If the underlying mechanisms fail, or S3 denies the request, or responds with something other than success, then my cb receives an appropriate err argument. Otherwise, the file is up there, everything is cleaned up, and the res argument is purely informative if I care.

Significantly, putFile can be promisified.

However, I see many (some old) issues that make me question this mental model. Maybe cb is called earlier than when it's all done? Maybe I need to parse Amazon response bodies? Switch on statuscode? I'm really not sure.

@bmustata
Copy link

bmustata commented Nov 9, 2016

Some more documentation will be very useful!

@SinisaG
Copy link

SinisaG commented Feb 22, 2017

Is not really like that. It looks like you'll get an error, that is before the request to s3 is issued. After you have to check the response for the error.

e.g.:

if (res.statusCode !== 200) {
   throw new Error("Something was not quite write");
}

I am struggling with this myself currently also and better documentation would for sure be more useful. In any case, thanks to the creators for their work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants