This commit is contained in:
Manav Rathi
2025-05-21 10:46:02 +05:30
parent 2cdeb88b4d
commit e022e7ae5b
2 changed files with 22 additions and 9 deletions

View File

@@ -7,6 +7,7 @@ import {
authenticatedRequestHeaders,
ensureOk,
retryAsyncOperation,
retryEnsuringHTTPOk,
type PublicAlbumsCredentials,
} from "ente-base/http";
import log from "ente-base/log";
@@ -271,10 +272,11 @@ export class PhotosUploadHTTPClient {
* Complete a multipart upload by reporting information about all the uploaded
* parts to the provided {@link completionURL}.
*
* @param completionURL The URL to which the final status of the uploaded parts
* should be reported to.
* @param completionURL A presigned URL to which the final status of the
* uploaded parts should be reported to.
*
* @param reqBody Information about the parts which were uploaded.
* @param reqBody A XML string containing information about the parts which were
* uploaded.
*
* [Note: Multipart uploads]
*
@@ -317,12 +319,18 @@ export class PhotosUploadHTTPClient {
* "completion URL" that we also got in step 1. Like step 2, there are 2
* variants of this - one where we directly tell the remote (S3), and one
* where we report via a worker.
*
*/
export const _completeMultipartUpload = async (completionURL: string) => {
}
export const _completeMultipartUpload = async (
completionURL: string,
reqBody: string,
) =>
retryEnsuringHTTPOk(() =>
fetch(completionURL, {
method: "POST",
headers: { "Content-Type": "text/xml" },
body: reqBody,
}),
);
/**
* Lowest layer for file upload related HTTP operations when we're running in

View File

@@ -53,6 +53,7 @@ import {
} from ".";
import { tryParseEpochMicrosecondsFromFileName } from "./date";
import {
_completeMultipartUpload,
PhotosUploadHTTPClient,
PublicAlbumsUploadHTTPClient,
type ObjectUploadURL,
@@ -1605,7 +1606,11 @@ async function uploadStreamUsingMultipart(
if (!isCFUploadProxyDisabled) {
await photosHTTPClient.completeMultipartUploadV2(completeURL, cBody);
} else {
await photosHTTPClient.completeMultipartUpload(completeURL, cBody);
if (process.env.NEXT_PUBLIC_ENTE_WIP_MP) {
await _completeMultipartUpload(completeURL, cBody);
} else {
await photosHTTPClient.completeMultipartUpload(completeURL, cBody);
}
}
return { objectKey: multipartUploadURLs.objectKey, fileSize };