@dimah-s3/server 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/plugins.js CHANGED
@@ -512,33 +512,29 @@ function listedPartsByteSize(parts, excludePartNumber) {
512
512
  }
513
513
  async function finalizeConfirmedObject(client, bucket, key, input) {
514
514
  const { config, route, stored, head, uploadId, acl } = input;
515
- const contentLength = requireContentLength(head);
516
- const fileName = resolveStoredFileName(head.ContentDisposition, key);
517
515
  const rawMetadata = head.Metadata ?? {};
516
+ const fileName = resolveStoredFileName(head.ContentDisposition, key);
517
+ let context;
518
518
  try {
519
+ const contentLength = requireContentLength(head);
519
520
  assertVerifiedConstraints(route.upload, {
520
521
  fileName,
521
522
  contentType: head.ContentType,
522
523
  contentLength
523
524
  });
524
- } catch (err) {
525
- await deleteObjectBestEffort(client, bucket, key);
526
- throw err;
527
- }
528
- const metadata = stripPreviousKeyMeta(rawMetadata);
529
- const context = {
530
- ...stored,
531
- contentType: head.ContentType,
532
- contentLength,
533
- eTag: head.ETag?.replace(/"/g, ""),
534
- metadata,
535
- acl,
536
- fileName,
537
- versionId: head.VersionId,
538
- lastModified: head.LastModified?.toISOString(),
539
- uploadId
540
- };
541
- try {
525
+ const metadata = stripPreviousKeyMeta(rawMetadata);
526
+ context = {
527
+ ...stored,
528
+ contentType: head.ContentType,
529
+ contentLength,
530
+ eTag: head.ETag?.replace(/"/g, ""),
531
+ metadata,
532
+ acl,
533
+ fileName,
534
+ versionId: head.VersionId,
535
+ lastModified: head.LastModified?.toISOString(),
536
+ uploadId
537
+ };
542
538
  await runLifecycleHook(route.upload.onConfirmed, context, config);
543
539
  } catch (err) {
544
540
  await deleteObjectBestEffort(client, bucket, key);
@@ -1044,6 +1040,17 @@ async function handleMultipartInit(config, input, request) {
1044
1040
  );
1045
1041
  } catch (err) {
1046
1042
  await abortMultipartBestEffort(route.client, bucket, key, UploadId);
1043
+ try {
1044
+ await runLifecycleHook(
1045
+ route.upload.multipart.onAbort,
1046
+ {
1047
+ ...stored,
1048
+ uploadId: UploadId
1049
+ },
1050
+ config
1051
+ );
1052
+ } catch {
1053
+ }
1047
1054
  throw err;
1048
1055
  }
1049
1056
  return { bucket, key, uploadId: UploadId };