Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: add abort multipart
Marc Seitz8c347cf051ee
diff --git a/pages/api/file/s3/multipart.ts b/pages/api/file/s3/multipart.tsindex 07c3d83d..fbff1cd2 100644--- a/pages/api/file/s3/multipart.ts+++ b/pages/api/file/s3/multipart.ts@@ -139,13 +139,40 @@ export default async function handler(},});- await client.send(completeCommand);+ try {+ await client.send(completeCommand);++ return res.status(200).json({+ success: true,+ key,+ fileName: slugifiedName,+ });+ } catch (completeError) {+ console.error("Failed to complete multipart upload:", completeError);++ // Cleanup: Abort the multipart upload to prevent storage costs+ try {+ const abortCommand = new AbortMultipartUploadCommand({+ Bucket: config.bucket,+ Key: key,+ UploadId: uploadId,+ });- return res.status(200).json({- success: true,- key,- fileName: slugifiedName,- });+ await client.send(abortCommand);+ console.log(`Successfully aborted multipart upload: ${uploadId}`);+ } catch (abortError) {+ console.error("Failed to abort multipart upload:", abortError);+ // Log but don't fail the request - the upload already failed+ }++ return res.status(500).json({+ error: "Failed to complete multipart upload",+ details:+ completeError instanceof Error+ ? completeError.message+ : "Unknown error",+ });+ }}default: