fix multipart upload merge file

This commit is contained in:
xlc
2024-05-16 13:33:53 +08:00
parent 69b8f42092
commit 9ff6e2d690
2 changed files with 68 additions and 1 deletions

View File

@@ -15,6 +15,8 @@ import (
"github.com/gogf/gf/v2/util/gconv"
"os"
"path/filepath"
"sort"
"strconv"
"strings"
)
@@ -139,7 +141,11 @@ func MergePartFile(srcPath, dstPath string) (err error) {
if err != nil {
return err
}
sort.Slice(dir, func(i, j int) bool {
fiIndex, _ := strconv.Atoi(dir[i].Name())
fjIndex, _ := strconv.Atoi(dir[j].Name())
return fiIndex < fjIndex
})
for _, file := range dir {
filePath := filepath.Join(srcPath, file.Name())
if err = gfile.PutBytesAppend(dstPath, gfile.GetBytes(filePath)); err != nil {