Open lishaoxin123 opened 2 years ago
需要buffer转stream,然后再调用sdk的上传接口。可参考以下代码:
let Duplex = require('stream').Duplex;
function bufferToStream(buffer) {
let stream = new Duplex();
stream.push(buffer);
stream.push(null);
return stream;
}
const buffers = []; // 文件buffer
const stream = bufferToStream(buffers);
obsClient.putObject({
Bucket : bucketName,
Key: 'objectname',
Body: stream
}).then(res => console.log(res));
https://support.huaweicloud.com/sdk-nodejs-devg-obs/obs_29_0404.html 只有文件的buffer流,怎么使用ObsClient 进行文件上传呢?总不能走一遍写入然后读取成功在删除吧。