-
Notifications
You must be signed in to change notification settings - Fork 1.5k
getObject returns corrupted file? #19
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
Comments
Answering my own question: var writePos = 0;
var stream = fs.createWriteStream("/tmp/test.jpg", { flags: 'w', encoding: null, mode: 0666 });
s3.client.getObject({ Bucket: bucket, Key: key }).data(function(data) {
stream.write(data.data);
}).done(function() {
stream.end();
}).send(); |
I've installed this package from master and this example has stopped working.
|
We've made changes to the Request class API since 0.9.1.pre-2. The changes are currently only in master and have not yet been released, so there isn't much available documentation. This will change by the next release, but to quickly get you going, you can rewrite the above as: var stream = fs.createWriteStream("/tmp/test.jpg", { flags: 'w', encoding: null, mode: 0666 });
s3.client.getObject({ Bucket: bucket, Key: key }).on('httpData', function(chunk) {
stream.write(chunk);
}).on('complete', function() {
stream.end();
}).send(); Note that we may be adding more streaming support before the next preview release, so the API might be simplified considerably to something like: var out = fs.createWriteStream("/tmp/test.jpg", { flags: 'w', encoding: null, mode: 0666 });
s3.client.getObject({ Bucket: bucket, Key: key }).createReadStream().pipe(out); I would suggest that you should run off of the npm package releases until the next preview is out unless you explicitly want to experiment with the current features that are in the works-- with the caveat that some documentation may not be in sync until we push out the next release. |
Yes, yes, I've found it. The changes were implemented here: #22, thank you. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
I trying different variants of this:
http://stackoverflow.com/questions/14020065/problems-downloading-a-binary-file-with-aws-sdk
I also seem to be getting a corrupted file, few KBs off. Do you have a working example?
The text was updated successfully, but these errors were encountered: