我在网站https://www.npmjs.com/package/ibm-cos-sdk中看到了示例代码:
function doCreateObject() {
console.log('Creating object');
return cos.putObject({
Bucket: 'my-bucket',
Key: 'foo',
Body: 'bar'
}).promise();
}
是否可以将流作为主体(例如正在上传的文件)提供,而不是一次提供整个主体?
答案 0 :(得分:1)
尝试:
var stream = fs.createReadStream('/Users/paulcarron/Desktop/image.jpeg');
function doCreateObject() {
console.log('Creating object');
return cos.putObject({
Bucket: bucket,
Key: 'foo.jpg',
Body: stream
}).promise();
}