π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Outline
Manav Rathi41b1638838e1
diff --git a/web/packages/gallery/services/file-data.ts b/web/packages/gallery/services/file-data.tsindex 20ae622f9a..bea4e25202 100644--- a/web/packages/gallery/services/file-data.ts+++ b/web/packages/gallery/services/file-data.ts@@ -385,13 +385,30 @@ const FilePreviewDataUploadURLResponse = z.object({objectID: z.string(),/*** A presigned URL that can be used to upload the file.+ *+ * This will be present only if we requested a singular object upload URL.+ */+ url: z.string().nullish().transform(nullToUndefined),+ /**+ * A list of pre-signed URLs that can be used to upload parts of a multipart+ * upload of the uploaded data.+ *+ * This will be present only if we requested a multipart upload URLs for the+ * object by setting `isMultiPart` true in the request.+ */+ partURLs: z.string().array().nullish().transform(nullToUndefined),+ /**+ * A pre-signed URL that can be used to finalize the multipart upload.+ *+ * This will be present only if we requested a multipart upload URLs for the+ * object by setting `isMultiPart` true in the request.*/- url: z.string(),+ completeURL: z.string().nullish().transform(nullToUndefined),});/**- * Obtain a presigned URL that can be used to upload the "file preview data" of- * type "vid_preview" (the file containing the encrypted video segments which+ * Obtain a presigned URL(s) that can be used to upload the "file preview data"+ * of type "vid_preview" (the file containing the encrypted video segments which* the "vid_preview" HLS playlist for the file would refer to).*/export const getFilePreviewDataUploadURL = async (file: EnteFile) => {diff --git a/web/packages/gallery/services/video.ts b/web/packages/gallery/services/video.tsindex 7824b72e9c..a09de25a2e 100644--- a/web/packages/gallery/services/video.ts+++ b/web/packages/gallery/services/video.ts@@ -995,14 +995,37 @@ const processQueueItem = async ({//// So instead we provide the presigned upload URL to the node side so that// it can directly upload the generated video segments.- const { objectID, url: objectUploadURL } =- await getFilePreviewDataUploadURL(file);+ const uploadURLs = await getFilePreviewDataUploadURL(file);++ const { objectID } = uploadURLs;++ // [Note: Passing HLS multipart upload URLs over IPC]+ //+ // For IPC convenience, we convert both normal upload URLs (where we have+ // only a single pre-signed URL) and multipart upload URLs (where we have a+ // list of pre-signed part upload URLs, and a completion URL) into an array.+ //+ // On the desktop side, we can parse the array and treat singleton arrays as+ // expecting a normal upload, and otherwise split the array into parts and+ // the completion URL (last item).+ let objectUploadURLs: string[];+ if (uploadURLs.url) {+ objectUploadURLs = [uploadURLs.url];+ } else if (uploadURLs.partURLs && uploadURLs.completeURL) {+ objectUploadURLs = [...uploadURLs.partURLs, uploadURLs.completeURL];+ } else {+ throw new Error("Malformed upload URLs");+ }log.info(`Generate HLS for ${fileLogID(file)} | start`);let res: GenerateHLSResult | undefined;try {- res = await initiateGenerateHLS(electron, sourceVideo, objectUploadURL);+ res = await initiateGenerateHLS(+ electron,+ sourceVideo,+ objectUploadURLs,+ );} catch (e) {// Failures during stream generation on the native side are expected to// happen in two cases:diff --git a/web/packages/gallery/utils/native-stream.ts b/web/packages/gallery/utils/native-stream.tsindex 4a3afb7ff9..304c81bffe 100644--- a/web/packages/gallery/utils/native-stream.ts+++ b/web/packages/gallery/utils/native-stream.ts@@ -205,9 +205,10 @@ export type GenerateHLSResult = z.infer<typeof GenerateHLSResult>;export const initiateGenerateHLS = async (_: Electron,video: FileSystemUploadItem | ReadableStream,- objectUploadURL: string,+ objectUploadURLs: string[],): Promise<GenerateHLSResult | undefined> => {- const params = new URLSearchParams({ op: "generate-hls", objectUploadURL });+ const params = new URLSearchParams({ op: "generate-hls" });+ for (const url of objectUploadURLs) params.append("url", url);let body: ReadableStream | null;if (video instanceof ReadableStream) {