@@ -176,7 +176,7 @@ export async function handlePostOrPut(
176176 }
177177 }
178178
179- const etag = isMPUComplete ? await handleMPUComplete ( request , env , uploadedParts ! ) : undefined
179+ const r2Object = isMPUComplete ? await handleMPUComplete ( request , env , uploadedParts ! ) : undefined
180180
181181 const originalMetadata = await getPasteMetadata ( env , pasteName )
182182 if ( originalMetadata === null ) {
@@ -193,7 +193,7 @@ export async function handlePostOrPut(
193193 expirationSeconds,
194194 now,
195195 passwd : newPasswd ,
196- contentLength,
196+ contentLength : r2Object ?. size || contentLength ,
197197 filename,
198198 highlightLanguage,
199199 encryptionScheme,
@@ -206,7 +206,7 @@ export async function handlePostOrPut(
206206 expirationSeconds,
207207 expireAt : new Date ( now . getTime ( ) + 1000 * expirationSeconds ) . toISOString ( ) ,
208208 } ,
209- { etag } ,
209+ { etag : r2Object ?. httpEtag } ,
210210 )
211211 } else {
212212 let pasteName : string | undefined
@@ -225,7 +225,7 @@ export async function handlePostOrPut(
225225 pasteName = genRandStr ( isPrivate ? PRIVATE_PASTE_NAME_LEN : PASTE_NAME_LEN )
226226 }
227227
228- const etag = isMPUComplete ? await handleMPUComplete ( request , env , uploadedParts ! ) : undefined
228+ const r2Object = isMPUComplete ? await handleMPUComplete ( request , env , uploadedParts ! ) : undefined
229229
230230 const password = passwdFromForm || genRandStr ( DEFAULT_PASSWD_LEN )
231231 await createPaste ( env , pasteName , content , {
@@ -234,7 +234,7 @@ export async function handlePostOrPut(
234234 passwd : password ,
235235 filename,
236236 highlightLanguage,
237- contentLength,
237+ contentLength : r2Object ?. size || contentLength ,
238238 encryptionScheme,
239239 isMPUComplete,
240240 } )
@@ -246,7 +246,7 @@ export async function handlePostOrPut(
246246 expirationSeconds,
247247 expireAt : new Date ( now . getTime ( ) + 1000 * expirationSeconds ) . toISOString ( ) ,
248248 } ,
249- { etag } ,
249+ { etag : r2Object ?. httpEtag } ,
250250 )
251251 }
252252}
0 commit comments