mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-11-28 23:08:12 +09:00
add-file-to-drive - hashがstreamを受ける時、hashもまたstreamなのだ
This commit is contained in:
parent
377bd2be18
commit
a4e1259dd7
@ -94,13 +94,16 @@ export default (
|
||||
((): Promise<string> => new Promise((res, rej) => {
|
||||
const readable = fs.createReadStream(path);
|
||||
const hash = crypto.createHash('md5');
|
||||
const chunks = [];
|
||||
readable
|
||||
.on('error', rej)
|
||||
.on('end', () => {
|
||||
res(hash.digest('hex'));
|
||||
})
|
||||
.pipe(hash)
|
||||
.on('error', rej);
|
||||
.on('error', rej)
|
||||
.on('data', (chunk) => chunks.push(chunk))
|
||||
.on('end', () => {
|
||||
const buffer = Buffer.concat(chunks);
|
||||
res(buffer.toString('hex'));
|
||||
});
|
||||
}))(),
|
||||
// mime
|
||||
((): Promise<[string, string | null]> => new Promise((res, rej) => {
|
||||
|
Loading…
Reference in New Issue
Block a user