Cant save Read Stream to Amazon S3 using aws2js

综合技术 Node.js Recipes (源链)

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!


JavaScript Unit Testing for Humans JavaScript Unit Testing for Humans When it comes to writing an Unit Test for UI code, it is not difficult, but ...
Binary AST – Motivations and Design Decision... By Kannan Vijayan, Mike Hoye “The key to making programs fast is to make them do practically nothing.” - Mike Haertel, creator of GN...
📦 Create Guten Block: Create React WordPress #Gute... :raised_hands: I'm truly excited to release one of my best open source software packages called create-guten-block with which you can start crea...
Why I love Javascript Internet, web and computers are not just technologies. They are the reason why I love my job. I'm passionate about technologies especially web. I cr...
Google JavaScript 样式指南中13个值得注意的地方... 英文原文 Google JavaScript Style Guide 全文 1 使用空格而不是Tab // bad function foo() { ∙∙∙∙let name; }// bad function b...
Node.js Recipes责编内容来自:Node.js Recipes (源链) | 更多关于

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

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

使用声明 | 英豪名录