| @@ -2,6 +2,7 @@ package storage | |||
| import ( | |||
| "encoding/xml" | |||
| "errors" | |||
| "path" | |||
| "sort" | |||
| "strconv" | |||
| @@ -129,7 +130,7 @@ func NewMultiPartUpload(uuid string) (string, error) { | |||
| return core.NewMultipartUpload(bucketName, objectName, miniov6.PutObjectOptions{}) | |||
| } | |||
| func CompleteMultiPartUpload(uuid string, uploadID string) (string, error) { | |||
| func CompleteMultiPartUpload(uuid string, uploadID string, totalChunks int) (string, error) { | |||
| client, core, err := getClients() | |||
| if err != nil { | |||
| log.Error("getClients failed:", err.Error()) | |||
| @@ -146,6 +147,11 @@ func CompleteMultiPartUpload(uuid string, uploadID string) (string, error) { | |||
| return "", err | |||
| } | |||
| if len(partInfos) != totalChunks { | |||
| log.Error("ListObjectParts number(%d) is not equal the set total chunk number(%d)", len(partInfos), totalChunks) | |||
| return "", errors.New("the parts is not complete") | |||
| } | |||
| var complMultipartUpload completeMultipartUpload | |||
| for _, partInfo := range partInfos { | |||
| complMultipartUpload.Parts = append(complMultipartUpload.Parts, miniov6.CompletePart{ | |||
| @@ -85,7 +85,7 @@ func listAllParts(uuid, uploadID, key string) (output *obs.ListPartsOutput, err | |||
| }) | |||
| } | |||
| if len(temp.Parts) < temp.MaxParts { | |||
| if !temp.IsTruncated { | |||
| break | |||
| } else { | |||
| continue | |||
| @@ -128,7 +128,7 @@ func NewObsMultiPartUpload(uuid, fileName string) (string, error) { | |||
| return output.UploadId, nil | |||
| } | |||
| func CompleteObsMultiPartUpload(uuid, uploadID, fileName string) error { | |||
| func CompleteObsMultiPartUpload(uuid, uploadID, fileName string, totalChunks int) error { | |||
| input := &obs.CompleteMultipartUploadInput{} | |||
| input.Bucket = setting.Bucket | |||
| input.Key = strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid, fileName)), "/") | |||
| @@ -140,6 +140,11 @@ func CompleteObsMultiPartUpload(uuid, uploadID, fileName string) error { | |||
| return err | |||
| } | |||
| if len(allParts.Parts) != totalChunks { | |||
| log.Error("listAllParts number(%d) is not equal the set total chunk number(%d)", len(allParts.Parts), totalChunks) | |||
| return errors.New("the parts is not complete") | |||
| } | |||
| input.Parts = allParts.Parts | |||
| output, err := ObsCli.CompleteMultipartUpload(input) | |||
| @@ -855,13 +855,13 @@ func CompleteMultipart(ctx *context.Context) { | |||
| } | |||
| if typeCloudBrain == models.TypeCloudBrainOne { | |||
| _, err = storage.CompleteMultiPartUpload(uuid, uploadID) | |||
| _, err = storage.CompleteMultiPartUpload(uuid, uploadID, fileChunk.TotalChunks) | |||
| if err != nil { | |||
| ctx.Error(500, fmt.Sprintf("CompleteMultiPartUpload failed: %v", err)) | |||
| return | |||
| } | |||
| } else { | |||
| err = storage.CompleteObsMultiPartUpload(uuid, uploadID, fileName) | |||
| err = storage.CompleteObsMultiPartUpload(uuid, uploadID, fileName, fileChunk.TotalChunks) | |||
| if err != nil { | |||
| ctx.Error(500, fmt.Sprintf("CompleteObsMultiPartUpload failed: %v", err)) | |||
| return | |||
| @@ -34,7 +34,6 @@ import { | |||
| } from './features/notification.js'; | |||
| import {createCodeEditor} from './features/codeeditor.js'; | |||
| import MinioUploader from './components/MinioUploader.vue'; | |||
| import ObsUploader from './components/ObsUploader.vue'; | |||
| import EditAboutInfo from './components/EditAboutInfo.vue'; | |||
| // import Images from './components/Images.vue'; | |||
| import EditTopics from './components/EditTopics.vue'; | |||
| @@ -2958,7 +2957,6 @@ $(document).ready(async () => { | |||
| initCodeView(); | |||
| initVueApp(); | |||
| initVueUploader(); | |||
| initObsUploader(); | |||
| initVueDataset(); | |||
| initVueEditAbout(); | |||
| initVueEditTopic(); | |||
| @@ -3854,8 +3852,7 @@ function initVueDataset() { | |||
| }, | |||
| }, | |||
| components: { | |||
| MinioUploader, | |||
| ObsUploader | |||
| MinioUploader | |||
| }, | |||
| mounted(){ | |||
| // if(document.getElementById('postPath')){ | |||
| @@ -4380,19 +4377,6 @@ function initVueDataAnalysis() { | |||
| render: h => h(DataAnalysis) | |||
| }); | |||
| } | |||
| // 新增 | |||
| function initObsUploader() { | |||
| const el = document.getElementById('obsUploader'); | |||
| if (!el) { | |||
| return; | |||
| } | |||
| new Vue({ | |||
| el: '#obsUploader', | |||
| components: {ObsUploader}, | |||
| template: '<ObsUploader />' | |||
| }); | |||
| } | |||
| function initVueWxAutorize() { | |||
| const el = document.getElementById('WxAutorize'); | |||
| if (!el) { | |||