Cant save Read Stream to Amazon S3 using aws2js

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)´

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( );                  

s3.putStream(savePath, fileStream, 'public-read', {'content-type': file.type.mime, 'content-length':file.length}, function (err, s3File) {
    if (err){
    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!

稿源:Node.js Recipes (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » Cant save Read Stream to Amazon S3 using aws2js

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录