Fixes uploaded to sort completedParts before completing the upload

This commit is contained in:
Rob Watson 2021-11-22 18:54:31 +01:00
parent f91a84b7eb
commit 7eef0b6e25
1 changed files with 6 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"io" "io"
"log" "log"
"sort"
"sync" "sync"
"github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws"
@ -187,6 +188,11 @@ outer:
uploadedBytes += result.size 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{ completeInput := s3.CompleteMultipartUploadInput{
Bucket: aws.String(bucket), Bucket: aws.String(bucket),
Key: aws.String(key), Key: aws.String(key),