2013-01-13 4 views
0

Knox S3 모듈을 사용하고 있지만 결국 파일을 가져올 때 결과 파일이 손상됩니다. Knox를 잘못 사용하고 있습니까?녹스 모듈의 응답을 어떻게 소비합니까?

var fs = require('fs'); 
var file = fs.createWriteStream(path); 
client.getFile(path, function(err, stream) { 
    stream.on('data', function(chunk) { file.write(chunk); }); 
    stream.on('end', function(chunk) { file.end(); }); 
}); 

을하고 그냥 명시 적 아마존의 자신의 SDK를 공개 주셔서 감사합니다 https://github.com/aws/aws-sdk-js

답변

1

는 writeStream를 사용해보십시오. 내가 어떻게 그것을 놓쳤는 지 명확히하지 않는다!
+0

에서 살펴해야합니다 :

 var data; client.getFile(path, function(err, file) { file.on('data', function(chunk) { data += chunk; }); file.on('end', function() { //Here I end up sending the response with new Buffer(data), but that produces a bad file. }); }); 
Benny

+0

@yonatan : fixed – Chris

관련 문제