Skip to content

Commit

Permalink
FIX mutiple files assert issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
karminski committed Nov 9, 2023
1 parent 8409dfa commit 451ee73
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
54 changes: 30 additions & 24 deletions src/actionruntime/illadrive/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func extractGetUploadAddressOperationParams(actionOptions map[string]interface{}
case "overwriteDuplicate":
valueAsserted, ValueAssertPass := value.(bool)
if !ValueAssertPass {
return false, "", "", 0, "", errors.New("field path assert failed")
return false, "", "", 0, "", errors.New("field overwriteDuplicate assert failed")
}
overwriteDuplicate = valueAsserted
case "path":
Expand All @@ -286,19 +286,19 @@ func extractGetUploadAddressOperationParams(actionOptions map[string]interface{}
case "fileName":
valueAsserted, ValueAssertPass := value.(string)
if !ValueAssertPass {
return false, "", "", 0, "", errors.New("field path assert failed")
return false, "", "", 0, "", errors.New("field fileName assert failed")
}
fileName = valueAsserted
case "fileSize":
valueAsserted, ValueAssertPass := value.(float64)
if !ValueAssertPass {
return false, "", "", 0, "", errors.New("field path assert failed")
return false, "", "", 0, "", errors.New("field fileSize assert failed")
}
fileSize = int64(valueAsserted)
case "contentType":
valueAsserted, ValueAssertPass := value.(string)
if !ValueAssertPass {
return false, "", "", 0, "", errors.New("field path assert failed")
return false, "", "", 0, "", errors.New("field contentType assert failed")
}
contentType = valueAsserted
}
Expand Down Expand Up @@ -351,30 +351,36 @@ func extractGetMutipleUploadAddressOperationParams(actionOptions map[string]inte
}
path = valueAsserted
case "files":
filesAsserted, filesAssertPass := value.(map[string]interface{})
filesAsserted, filesAssertPass := value.([]interface{})
if !filesAssertPass {
return false, "", []string{}, []int64{}, []string{}, errors.New("field files assert failed")
}
for subKey, subValue := range filesAsserted {
switch subKey {
case "fileName":
subValueAsserted, subValueAssertPass := subValue.(string)
if !subValueAssertPass {
return false, "", []string{}, []int64{}, []string{}, errors.New("field fileName assert failed")
}
fileNames = append(fileNames, subValueAsserted)
case "fileSize":
subValueAsserted, subValueAssertPass := subValue.(float64)
if !subValueAssertPass {
return false, "", []string{}, []int64{}, []string{}, errors.New("field fileSize assert failed")
}
fileSizes = append(fileSizes, int64(subValueAsserted))
case "contentType":
subValueAsserted, subValueAssertPass := subValue.(string)
if !subValueAssertPass {
return false, "", []string{}, []int64{}, []string{}, errors.New("field fileSize assert failed")
for _, file := range filesAsserted {
fileAsserted, fileAssertPass := file.(map[string]interface{})
if !fileAssertPass {
return false, "", []string{}, []int64{}, []string{}, errors.New("field file in files assert failed")
}
for subKey, subValue := range fileAsserted {
switch subKey {
case "fileName":
subValueAsserted, subValueAssertPass := subValue.(string)
if !subValueAssertPass {
return false, "", []string{}, []int64{}, []string{}, errors.New("field fileName assert failed")
}
fileNames = append(fileNames, subValueAsserted)
case "fileSize":
subValueAsserted, subValueAssertPass := subValue.(float64)
if !subValueAssertPass {
return false, "", []string{}, []int64{}, []string{}, errors.New("field fileSize assert failed")
}
fileSizes = append(fileSizes, int64(subValueAsserted))
case "contentType":
subValueAsserted, subValueAssertPass := subValue.(string)
if !subValueAssertPass {
return false, "", []string{}, []int64{}, []string{}, errors.New("field contentType assert failed")
}
contentTypes = append(contentTypes, subValueAsserted)
}
contentTypes = append(contentTypes, subValueAsserted)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/utils/illadrivesdk/illa_drive_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,10 @@ func (r *IllaDriveRestAPI) UpdateFileStatus(teamID int, fileID string, status st

func (r *IllaDriveRestAPI) GetMultipleUploadAddress(teamID int, overwriteDuplicate bool, path string, fileNames []string, fileSizes []int64, contentTypes []string) ([]map[string]interface{}, error) {
ret := make([]map[string]interface{}, 0)
fmt.Printf("[DUMP] GetMultipleUploadAddress() fileName: %+v, fileSizes: %+v, contentTypes: %+v\n ", fileNames, fileSizes, contentTypes)
for serial, fileName := range fileNames {
uploadAddressInfo, errInGetUploadAddress := r.GetUploadAddres(teamID, overwriteDuplicate, path, fileName, fileSizes[serial], contentTypes[serial])
fmt.Printf("[DUMP] uploadAddressInfo[%d]: %+v\n", serial, uploadAddressInfo)
if errInGetUploadAddress != nil {
return nil, errInGetUploadAddress
}
Expand Down

0 comments on commit 451ee73

Please sign in to comment.