Joyent의 Manta 's Node.js SDK를 사용하여 읽을 수있는 스트림에서 파일을 쓰려고합니다.Joyent Manta client.createWriteStream (path, options)을 올바르게 사용하는 방법
웹 페이지에 주어진 예는 이것이다 :
var MemoryStream = require('memorystream');
var message = 'Hello World'
var opts = {
copies: 3,
headers: {
'access-control-allow-origin': '*',
'access-control-allow-methods': 'GET'
},
md5: crypto.createHash('md5').update(message).digest('base64'),
size: Buffer.byteLength(message),
type: 'text/plain'
};
var stream = new MemoryStream();
var w = client.createWriteStream('/jill/stor/hello_world.txt', opts);
stream.pipe(w);
w.once('close', function (res) {
console.log('all done');
});
stream.end(message);
을하지만이 경우 우리가 난을 전달하는 것을 원하는 경우, 프로그램에 이미 파일/객체/문자열을 넣어 writeStream를 사용하고 있습니다 읽을 수있는 스트림을 작성해야합니까?
function saveCopyToManta(cb){
var stream = fs.createReadStream('/tmp/' + filename);
var opts = {
copies: 3,
headers: {
'access-control-allow-origin': '*',
'access-control-allow-methods': 'GET'
},
md5: crypto.createHash('md5').update(message).digest('base64'),
size: filesize,
type: 'text/plain'
};
client.put('/someuser/stor/logs/+filename, stream, opts, function (err) {
if(err) cb(err);
else cb();
});
};
나는이 라인에 대해이 작업을 수행하려면 어떻게해야합니까 :
md5: crypto.createHash('md5').update(message).digest('base64'),
당신
고맙습니다, 이고르 :) –