Skip to content

armgit / ente

Public Imported from GitHub
0

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

Preview URL

Manav Rathi1370f0523cb9
diff --git a/web/packages/gallery/services/file-data.ts b/web/packages/gallery/services/file-data.ts
index 0a12061d50..c2b6101c04 100644
--- a/web/packages/gallery/services/file-data.ts
+++ b/web/packages/gallery/services/file-data.ts
@@ -225,6 +225,36 @@ export const fetchFilePreviewData = async (
return z.object({ url: z.string() }).parse(await res.json()).url;
};
+const FilePrevieDataUploadURLResponse = z.object({
+ /**
+ * The objectID with which this uploaded data can be referred to post upload
+ * (e.g. when invoking {@link putVideoData}).
+ */
+ objectID: z.string(),
+ /**
+ * A presigned URL that can be used to upload the file.
+ */
+ url: z.string(),
+});
+
+/**
+ * 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
+ * the "vid_preview" HLS playlist for the file would refer to).
+ */
+export const getFilePreviewDataUploadURL = async (file: EnteFile) => {
+ const params = new URLSearchParams({
+ fileID: `${file.id}`,
+ type: "vid_preview",
+ });
+ const url = await apiURL("/files/data/preview-upload-url");
+ const res = await fetch(`${url}?${params.toString()}`, {
+ headers: await authenticatedRequestHeaders(),
+ });
+ ensureOk(res);
+ return FilePrevieDataUploadURLResponse.parse(await res.json());
+};
+
/**
* Update the video data associated with the given file to remote.
*
diff --git a/web/packages/gallery/services/video.ts b/web/packages/gallery/services/video.ts
index a15ac068ea..90a9fdb1be 100644
--- a/web/packages/gallery/services/video.ts
+++ b/web/packages/gallery/services/video.ts
@@ -260,6 +260,11 @@ const PlaylistJSON = z.object({
* The height of the video (px).
*/
height: z.number(),
+ /**
+ * The size (in bytes) of the corresponding file containing the video
+ * segments that the playlist refers to.
+ */
+ size: z.number(),
});
const decryptPlaylistJSON = async (