This commit is contained in:
Worph
2025-02-20 16:41:04 +01:00
parent b64bc034c6
commit a7fef61c30
12 changed files with 124 additions and 52 deletions
+5 -3
View File
@@ -1,6 +1,8 @@
import {CID_ALGORITHM_NAMES} from "@root/hash-compute/MultiHashData";
import fs from "fs";
import {Readable} from 'stream';
import {computeCIDs as computeCIDsInternal} from "./ComputeHash";
import {createHasher} from "@root/file-id/CreateHasher";
/**
* Compute the CIDs of a file using specific algorithms
@@ -12,6 +14,6 @@ export default async function computeCIDs({filePath, algorithms}: {
filePath: string;
algorithms: CID_ALGORITHM_NAMES[]
}): Promise<string[]> {
const stream = fs.createReadStream(filePath);
return computeCIDsInternal({stream, algorithms});
}
const stream = Readable.toWeb(fs.createReadStream(filePath));
return computeCIDsInternal({stream, algorithms, createHasher});
}