Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: add logic to read a range of chunks

thecodrrd54b574c6032
diff --git a/apps/web/packages/streamablefs/src/filehandle.ts b/apps/web/packages/streamablefs/src/filehandle.ts
index 7f2a720b5..35a74f5ce 100644
--- a/apps/web/packages/streamablefs/src/filehandle.ts
+++ b/apps/web/packages/streamablefs/src/filehandle.ts
@@ -45,6 +45,16 @@ export default class FileHandle extends ReadableStream {
return array;
}
+ async readChunks(from: number, length: number): Promise<Blob> {
+ let blobParts: BlobPart[] = [];
+ for (let i = from; i < from + length; ++i) {
+ const array = await this.readChunk(i);
+ if (!array) continue;
+ blobParts.push(array.buffer);
+ }
+ return new Blob(blobParts, { type: this.file.type });
+ }
+
async toBlob() {
let blobParts: BlobPart[] = [];
for (let i = 0; i < this.file.chunks; ++i) {