Skip to content

Commit

Permalink
修复镜像回源、解冻对象、生成外链、批量删除接口的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
likui2 committed Nov 2, 2023
2 parents 0c0c392 + fffd769 commit c0fb853
Show file tree
Hide file tree
Showing 15 changed files with 778 additions and 525 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
vendor
doc
.idea/
.DS_Store
2 changes: 1 addition & 1 deletion aws/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ package aws
const SDKName = "aws-sdk-go"

// SDKVersion is the version of this SDK
const SDKVersion = "1.2.6"
const SDKVersion = "1.2.7"
56 changes: 56 additions & 0 deletions internal/protocol/body/body.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package body

import (
"github.com/ks3sdklib/aws-sdk-go/aws"
"github.com/ks3sdklib/aws-sdk-go/internal/protocol/rest"
"github.com/ks3sdklib/aws-sdk-go/internal/protocol/restjson"
"github.com/ks3sdklib/aws-sdk-go/internal/protocol/restxml"
)

// Build builds the REST component of a service request.
func Build(r *aws.Request) {
index := IndexOf(jsonRequestApiName, r.Operation.Name)
if index != -1 {
restjson.Build(r)
} else {
restxml.Build(r)
}
}

// UnmarshalBody unmarshal a response body for the REST protocol.
func UnmarshalBody(r *aws.Request) {
rest.Unmarshal(r)
index := IndexOf(jsonResponseApiName, r.Operation.Name)
if index != -1 {
restjson.Unmarshal(r)
} else {
restxml.Unmarshal(r)
}
}

// UnmarshalMeta unmarshal response headers for the REST protocol.
func UnmarshalMeta(r *aws.Request) {
rest.UnmarshalMeta(r)
}

// UnmarshalError unmarshal a response error for the REST protocol.
func UnmarshalError(r *aws.Request) {
restxml.UnmarshalError(r)
}

var jsonRequestApiName = []string{
"PutBucketMirror",
}

var jsonResponseApiName = []string{
"GetBucketMirror",
}

func IndexOf(apiNames []string, apiName string) int {
for index, value := range apiNames {
if value == apiName {
return index
}
}
return -1
}
31 changes: 27 additions & 4 deletions internal/protocol/jsonrpc/jsonrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package jsonrpc
import (
"encoding/json"
"io/ioutil"
"reflect"
"strings"

"github.com/ks3sdklib/aws-sdk-go/aws"
Expand All @@ -22,7 +23,18 @@ func Build(req *aws.Request) {
var buf []byte
var err error
if req.ParamsFilled() {
buf, err = jsonutil.BuildJSON(req.Params)
v := reflect.ValueOf(req.Params).Elem()
if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok {
if payloadName := field.Tag.Get("payload"); payloadName != "" {
pfield, _ := v.Type().FieldByName(payloadName)
if ptag := pfield.Tag.Get("type"); ptag == "" || ptag == "structure" {
payload := reflect.Indirect(v.FieldByName(payloadName))
if payload.IsValid() && payload.Interface() != nil {
buf, err = jsonutil.BuildJSON(payload.Interface())
}
}
}
}
if err != nil {
req.Error = apierr.New("Marshal", "failed encoding JSON RPC request", err)
return
Expand All @@ -49,9 +61,20 @@ func Build(req *aws.Request) {
func Unmarshal(req *aws.Request) {
defer req.HTTPResponse.Body.Close()
if req.DataFilled() {
err := jsonutil.UnmarshalJSON(req.Data, req.HTTPResponse.Body)
if err != nil {
req.Error = apierr.New("Unmarshal", "failed decoding JSON RPC response", err)
v := reflect.ValueOf(req.Data).Elem()
if field, ok := v.Type().FieldByName("SDKShapeTraits"); ok {
if payloadName := field.Tag.Get("payload"); payloadName != "" {
pfield, _ := v.Type().FieldByName(payloadName)
if ptag := pfield.Tag.Get("type"); ptag == "" || ptag == "structure" {
payload := v.FieldByName(payloadName)
if payload.IsValid() && payload.Interface() != nil {
err := jsonutil.UnmarshalJSON(payload.Interface(), req.HTTPResponse.Body)
if err != nil {
req.Error = apierr.New("Unmarshal", "failed decoding JSON RPC response", err)
}
}
}
}
}
}
return
Expand Down
6 changes: 6 additions & 0 deletions internal/protocol/rest/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ func Unmarshal(r *aws.Request) {
if r.DataFilled() {
v := reflect.Indirect(reflect.ValueOf(r.Data))
unmarshalBody(r, v)
}
}

func UnmarshalMeta(r *aws.Request) {
if r.DataFilled() {
v := reflect.Indirect(reflect.ValueOf(r.Data))
unmarshalLocationElements(r, v)
}
}
Expand Down
1 change: 1 addition & 0 deletions internal/signer/v2/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var signQuerys = map[string]bool{
"fetch": true,
"copy": true,
"mirror": true,
"restore": true,
}

type signer struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/signer/v4/v4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func buildSigner(serviceName string, region string, signTime time.Time, expireTi
return signer{
Request: req,
Time: signTime,
ExpireTime: expireTime,
ExpireTime: int64(expireTime),
Query: req.URL.Query(),
Body: reader,
ServiceName: serviceName,
Expand Down
Loading

0 comments on commit c0fb853

Please sign in to comment.