MCPcopy Create free account
hub / github.com/ProtonDriveApps/sdk / readStreamContent

Function readStreamContent

client/js/src/internal/upload/smallFileUploader.ts:108–136  ·  view source on GitHub ↗
(stream: ReadableStream)

Source from the content-addressed store, hash-verified

106 encryptedThumbnails,
107 };
108 }
109
110 private async readStreamContent(stream: ReadableStream): Promise<{
111 data: Uint8Array<ArrayBuffer>;
112 sha1: string;
113 }> {
114 const content = await readStreamToUint8Array(stream, this.abortController.signal);
115
116 if (content.length !== this.metadata.expectedSize) {
117 throw new IntegrityError(c('Error').t`Some file data failed to upload. Please try again.`, {
118 actual: content.length,
119 expected: this.metadata.expectedSize,
120 });
121 }
122
123 const digests = new UploadDigests();
124 digests.update(content);
125 const contentSha1 = digests.digests().sha1;
126
127 if (this.metadata.expectedSha1 && contentSha1 !== this.metadata.expectedSha1) {
128 throw new IntegrityError(c('Error').t`The uploaded file does not match the original. Please try again.`, {
129 uploadedSha1: contentSha1,
130 expectedSha1: this.metadata.expectedSha1,
131 });
132 }
133
134 return {
135 data: content,
136 sha1: contentSha1,
137 };
138 }
139

Callers

nothing calls this directly

Calls 3

updateMethod · 0.95
digestsMethod · 0.95
readStreamToUint8ArrayFunction · 0.90

Tested by

no test coverage detected