mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
fs_upload支持redirect字段,添加stream2buffer函数
This commit is contained in:
1 parent
86689e8d4c
commit
327fec1fea
5 files changed
+32
-6
No files matched your search
@@ -170,3 +170,12 @@ export function isClass(obj: any, strict = false) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function streamToBuffer(stream): Promise<Buffer> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const buffers = [];
|
||||
stream.on('error', reject);
|
||||
stream.on('data', (data) => buffers.push(data));
|
||||
stream.on('end', () => resolve(Buffer.concat(buffers)));
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user