π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
gz
Manav Rathifd49211a0a5e
diff --git a/web/packages/new/photos/services/ml/embedding.ts b/web/packages/new/photos/services/ml/embedding.tsindex 7ed4892b9a..b7f3fca1cd 100644--- a/web/packages/new/photos/services/ml/embedding.ts+++ b/web/packages/new/photos/services/ml/embedding.ts@@ -309,6 +309,7 @@ const putEmbedding = async (});ensureOk(res);};+/*** Upload an embedding to remote.*@@ -350,7 +351,29 @@ export const putDerivedData = async (};log.debug(() => ["Uploading derived data", combined]);- return putEmbeddingString(enteFile, "combined", JSON.stringify(combined));+ return putEmbedding(+ enteFile,+ "combined",+ await gzip(JSON.stringify(combined)),+ );+};++/**+ * Compress the given {@link string} using "gzip" and return the resultant+ * bytes.+ *+ * This is syntactic sugar to deal with the string/blob/stream/bytes+ * conversions, but it should not be taken as an abstraction layer. If your code+ * can directly use a ReadableStream, then then data -> stream -> data round+ * trip is unnecessary.+ */+const gzip = async (string: string) => {+ const compressedStream = new Blob([string])+ .stream()+ // This code only runs on the desktop app currently, so we can rely on+ // the existence of the CompressionStream API.+ .pipeThrough(new CompressionStream("gzip"));+ return new Uint8Array(await new Response(compressedStream).arrayBuffer());};// MARK: - Facediff --git a/web/packages/next/blob-cache.ts b/web/packages/next/blob-cache.tsindex 750f3effd8..dae10f7725 100644--- a/web/packages/next/blob-cache.ts+++ b/web/packages/next/blob-cache.ts@@ -143,6 +143,13 @@ export const openBlobCache = async (* To convert from a Uint8Array/ArrayBuffer/Blob to a ReadableStream** new Response(array).body+ * OR+ * new Blob([...]).stream()+ *+ * To convert from a stream to a string (or JSON)+ *+ * await new Response(stream).text()+ * await new Response(stream).json()** Refs:* - https://github.com/yigitunallar/arraybuffer-vs-blob