Skip to content

armgit / ente

Public Imported from GitHub
0

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

Add cache busting to upload URL endpoints to prevent reuse

Manav Rathif0d1ec4e6584
diff --git a/desktop/src/main/services/ffmpeg-worker.ts b/desktop/src/main/services/ffmpeg-worker.ts
index b63abcf023..e64336c7fc 100644
--- a/desktop/src/main/services/ffmpeg-worker.ts
+++ b/desktop/src/main/services/ffmpeg-worker.ts
@@ -934,6 +934,7 @@ export const getFilePreviewDataUploadURL = async (
const params = new URLSearchParams({
fileID: fileID.toString(),
type: "vid_preview",
+ ts: Date.now().toString(),
});
if (partCount > 1) {
params.set("isMultiPart", "true");
diff --git a/web/packages/gallery/services/upload/remote.ts b/web/packages/gallery/services/upload/remote.ts
index d5eb0859ae..0d475163ef 100644
--- a/web/packages/gallery/services/upload/remote.ts
+++ b/web/packages/gallery/services/upload/remote.ts
@@ -45,9 +45,12 @@ const ObjectUploadURLResponse = z.object({ urls: ObjectUploadURL.array() });
*/
export const fetchUploadURLs = async (countHint: number) => {
const count = Math.min(50, countHint * 2);
- const res = await fetch(await apiURL("/files/upload-urls", { count }), {
- headers: await authenticatedRequestHeaders(),
- });
+ const res = await fetch(
+ await apiURL("/files/upload-urls", { count, ts: Date.now() }),
+ {
+ headers: await authenticatedRequestHeaders(),
+ },
+ );
ensureOk(res);
return ObjectUploadURLResponse.parse(await res.json()).urls;
};
@@ -61,7 +64,7 @@ export const fetchPublicAlbumsUploadURLs = async (
) => {
const count = Math.min(50, countHint * 2);
const res = await fetch(
- await apiURL("/public-collection/upload-urls", { count }),
+ await apiURL("/public-collection/upload-urls", { count, ts: Date.now() }),
{ headers: authenticatedPublicAlbumsRequestHeaders(credentials) },
);
ensureOk(res);
@@ -113,7 +116,7 @@ const MultipartUploadURLsResponse = z.object({ urls: MultipartUploadURLs });
export const fetchMultipartUploadURLs = async (uploadPartCount: number) => {
const count = uploadPartCount;
const res = await fetch(
- await apiURL("/files/multipart-upload-urls", { count }),
+ await apiURL("/files/multipart-upload-urls", { count, ts: Date.now() }),
{ headers: await authenticatedRequestHeaders() },
);
ensureOk(res);
@@ -129,7 +132,10 @@ export const fetchPublicAlbumsMultipartUploadURLs = async (
) => {
const count = uploadPartCount;
const res = await fetch(
- await apiURL("/public-collection/multipart-upload-urls", { count }),
+ await apiURL("/public-collection/multipart-upload-urls", {
+ count,
+ ts: Date.now(),
+ }),
{ headers: authenticatedPublicAlbumsRequestHeaders(credentials) },
);
ensureOk(res);