From 7eef0b6e25c7d70acf382c40ac8232fe37351aca Mon Sep 17 00:00:00 2001 From: Rob Watson Date: Mon, 22 Nov 2021 18:54:31 +0100 Subject: [PATCH] Fixes uploaded to sort completedParts before completing the upload --- backend/media/uploader.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/media/uploader.go b/backend/media/uploader.go index ce1a509..3cc3c15 100644 --- a/backend/media/uploader.go +++ b/backend/media/uploader.go @@ -7,6 +7,7 @@ import ( "fmt" "io" "log" + "sort" "sync" "github.com/aws/aws-sdk-go-v2/aws" @@ -187,6 +188,11 @@ outer: uploadedBytes += result.size } + // the parts may be out of order, especially with slow network conditions: + sort.Slice(completedParts, func(i, j int) bool { + return completedParts[i].PartNumber < completedParts[j].PartNumber + }) + completeInput := s3.CompleteMultipartUploadInput{ Bucket: aws.String(bucket), Key: aws.String(key),