In my node.js app I’m uploading a file (which is saved to local filesystem -> /tmp/) from which I create a Stream of, to store that file into my S3bucket using aws2js (Amazon CLI bindings).The problem starts with trying to initially save the file to S3 with putStream(…), before I do any further manipulations. (using ´putFile(filepath)´ works!)
The Entry in my Bucket is created and no error is given with the callback. But no file-content has been saved and the Entry has 0 bytes.
Following, my code;
....
var fileStream=fs.createReadStream(file.path),
savePath = _makeSavePath( file.name );
s3.putStream(savePath, fileStream, 'public-read', {'content-type': file.type.mime, 'content-length':file.length}, function (err, s3File) {
if (err){
console.error(err);
fileGetCB(err);
return;
}
console.log("SAVED TO S3 '"+savePath+"'!!");
//do further manipulations with fileStream
});
...
I can assure, that file is initialized and that the file at file.path exists.
The reason why I’m using a stream and not using S3.putFile(path) is because I’ll be further manipulating the file. By using a stream I could later reuse so that not every module has to re-read the whole file (maybe its not even possible to ‘reuse’ a stream, but thats not the problem (yet).. )
I am very helpful for any hand in any direction, since I cant figure out why this isn’t working for 4days of try&fail. Thank you!
Actually, I made a mistake in my original post on GitHub. aws2js changed internally the way that a Stream is uploaded to S3.
As for node.js v0.6.9, it isn’t unstable per se, but it has a broken handling of Expect: 100-continue.