Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

PUT video-data

Manav Rathib4d532bb415f
diff --git a/desktop/src/main/stream.ts b/desktop/src/main/stream.ts
index 7e4a70dbff..b5d497d053 100644
--- a/desktop/src/main/stream.ts
+++ b/desktop/src/main/stream.ts
@@ -291,9 +291,6 @@ const handleGenerateHLSWrite = async (request: Request) => {
inputTempFilePath,
outputFilePathPrefix,
);
- } catch (e) {
- log.error("Generate HLS failed", e);
- throw e;
} finally {
await deleteTempFileIgnoringErrors(inputTempFilePath);
}
diff --git a/web/packages/gallery/services/file-data.ts b/web/packages/gallery/services/file-data.ts
index 666367dac9..0a12061d50 100644
--- a/web/packages/gallery/services/file-data.ts
+++ b/web/packages/gallery/services/file-data.ts
@@ -8,6 +8,7 @@ import {
import { apiURL } from "ente-base/origins";
import type { EnteFile } from "ente-media/file";
import { z } from "zod";
+
/**
* [Note: File data APIs]
*
@@ -223,3 +224,53 @@ export const fetchFilePreviewData = async (
ensureOk(res);
return z.object({ url: z.string() }).parse(await res.json()).url;
};
+
+/**
+ * Update the video data associated with the given file to remote.
+ *
+ * Video data refers to two things:
+ *
+ * - The encrypted HLS playlist ("file data" of type "vid_preview").
+ *
+ * - The object ID of an (already uploaded) "file preview data" file containing
+ * the video segments.
+ *
+ * This function is similar to {@link putFileData}, except it will save or
+ * update the both the playlist and the reference to its associated segment file
+ * associated with the given {@link file}. The playlist data will be end-to-end
+ * encrypted using the given {@link file}'s key before uploading.
+ *
+ * @param file {@link EnteFile} which this data is associated with.
+ *
+ * @param playlistData The HLS playlist contents, as a {@link Blob}.
+ *
+ * @param objectID Object ID of an already uploaded "file preview data" (see
+ * {@link getFilePreviewDataUploadURL}).
+ *
+ * @param objectSize The size (in bytes) of the file corresponding to
+ * {@link objectID}.
+ */
+export const putVideoData = async (
+ file: EnteFile,
+ playlistData: Uint8Array,
+ objectID: string,
+ objectSize: number,
+) => {
+ const { encryptedData, decryptionHeader } = await encryptBlobB64(
+ playlistData,
+ file.key,
+ );
+
+ const res = await fetch(await apiURL("/files/video-data"), {
+ method: "PUT",
+ headers: await authenticatedRequestHeaders(),
+ body: JSON.stringify({
+ fileID: file.id,
+ objectID,
+ objectSize,
+ playlist: encryptedData,
+ playlistHeader: decryptionHeader,
+ }),
+ });
+ ensureOk(res);
+};