Skip to content

Commit

Permalink
update 3.24.6
Browse files Browse the repository at this point in the history
  • Loading branch information
noaccident committed Jul 7, 2024
1 parent fed907b commit 5105f9c
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 22 deletions.
13 changes: 13 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
Version 3.24.6

New Features:
1. Supports passing metadata when use CopyObject and InitiateMultipartUpload mehod.

Documentation & Demo:

Resolved Issues:
1. Fixed the issue where bucket acl configuration failed in some scenarios.
2. Fixed the issue where data transmission exception in retry scenarios.

-----------------------------------------------------------------------------------

Version 3.24.3

New Features:
Expand Down
14 changes: 14 additions & 0 deletions README_CN.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
Version 3.24.6

新特性:
1. 支持在使用CopyObject和InitiateMultipartUpload方法时传递元数据信息。

资料 & demo:

修复问题:

1. 修复部分场景下bucket acl配置失败的问题。
2. 修复重试场景下数据传输异常的问题。

-----------------------------------------------------------------------------------

Version 3.24.3

新特性:
Expand Down
5 changes: 3 additions & 2 deletions obs/client_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,9 @@ func (obsClient ObsClient) getBucketACLObs(bucketName string, extensions []exten
tempOutput.Grantee.DisplayName = valGrant.Grantee.DisplayName
tempOutput.Grantee.ID = valGrant.Grantee.ID
tempOutput.Grantee.Type = valGrant.Grantee.Type
tempOutput.Grantee.URI = GroupAllUsers

if valGrant.Grantee.Canned == "Everyone" {
tempOutput.Grantee.URI = GroupAllUsers
}
output.Grants = append(output.Grants, tempOutput)
}
}
Expand Down
1 change: 1 addition & 0 deletions obs/client_part.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func (obsClient ObsClient) UploadPart(_input *UploadPartInput, extensions ...ext
input.PartSize = fileSize - input.Offset
}
fileReaderWrapper.totalCount = input.PartSize
fileReaderWrapper.mark = input.Offset
if _, err = fd.Seek(input.Offset, io.SeekStart); err != nil {
return nil, err
}
Expand Down
8 changes: 5 additions & 3 deletions obs/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ type config struct {
}

func (conf config) String() string {
return fmt.Sprintf("[endpoint:%s, signature:%s, pathStyle:%v, region:%s"+
"\nconnectTimeout:%d, socketTimeout:%dheaderTimeout:%d, idleConnTimeout:%d"+
"\nmaxRetryCount:%d, maxConnsPerHost:%d, sslVerify:%v, maxRedirectCount:%d]",
return fmt.Sprintf("[endpoint:%s, signature:%s, pathStyle:%v, region:%s,"+
"\nconnectTimeout:%d, socketTimeout:%d, headerTimeout:%d, idleConnTimeout:%d,"+
"\nmaxRetryCount:%d, maxConnsPerHost:%d, sslVerify:%v, maxRedirectCount:%d,"+
"\ncname:%v, userAgent:%s, disableKeepAlive:%v, proxyFromEnv:%v]",
conf.endpoint, conf.signature, conf.pathStyle, conf.region,
conf.connectTimeout, conf.socketTimeout, conf.headerTimeout, conf.idleConnTimeout,
conf.maxRetryCount, conf.maxConnsPerHost, conf.sslVerify, conf.maxRedirectCount,
conf.cname, conf.userAgent, conf.disableKeepAlive, conf.proxyFromEnv,
)
}

Expand Down
2 changes: 1 addition & 1 deletion obs/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
package obs

const (
OBS_SDK_VERSION = "3.23.12"
OBS_SDK_VERSION = "3.24.6"
USER_AGENT = "obs-sdk-go/" + OBS_SDK_VERSION
HEADER_PREFIX = "x-amz-"
HEADER_PREFIX_META = "x-amz-meta-"
Expand Down
32 changes: 24 additions & 8 deletions obs/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,31 @@ func ParseStringToFSStatusType(value string) (ret FSStatusType) {
return
}

func prepareGrantURI(grant Grant) string {
if grant.Grantee.URI == GroupAllUsers || grant.Grantee.URI == GroupAuthenticatedUsers {
return fmt.Sprintf("<URI>%s%s</URI>", "http://acs.amazonaws.com/groups/global/", grant.Grantee.URI)
func prepareGrantURI(grantUri GroupUriType) string {
if grantUri == GroupAllUsers || grantUri == GroupAuthenticatedUsers {
return fmt.Sprintf("<URI>%s%s</URI>", "http://acs.amazonaws.com/groups/global/", grantUri)
}
if grant.Grantee.URI == GroupLogDelivery {
return fmt.Sprintf("<URI>%s%s</URI>", "http://acs.amazonaws.com/groups/s3/", grant.Grantee.URI)
if grantUri == GroupLogDelivery {
return fmt.Sprintf("<URI>%s%s</URI>", "http://acs.amazonaws.com/groups/s3/", grantUri)
}
return fmt.Sprintf("<URI>%s</URI>", grant.Grantee.URI)
return fmt.Sprintf("<URI>%s</URI>", grantUri)
}

func convertGrantToXML(grant Grant, isObs bool, isBucket bool) string {
xml := make([]string, 0, 4)

if grant.Grantee.ID != "" &&
grant.Grantee.URI == "" &&
grant.Grantee.Type == "" {
grant.Grantee.Type = GranteeUser
}

if grant.Grantee.URI != "" &&
grant.Grantee.ID == "" &&
grant.Grantee.Type == "" {
grant.Grantee.Type = GranteeGroup
}

if grant.Grantee.Type == GranteeUser {
if isObs {
xml = append(xml, "<Grant><Grantee>")
Expand All @@ -126,7 +138,7 @@ func convertGrantToXML(grant Grant, isObs bool, isBucket bool) string {
} else {
if !isObs {
xml = append(xml, fmt.Sprintf("<Grant><Grantee xsi:type=\"%s\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">", grant.Grantee.Type))
xml = append(xml, prepareGrantURI(grant))
xml = append(xml, prepareGrantURI(grant.Grantee.URI))
xml = append(xml, "</Grantee>")
} else if grant.Grantee.URI == GroupAllUsers {
xml = append(xml, "<Grant><Grantee>")
Expand Down Expand Up @@ -157,7 +169,11 @@ func ConvertLoggingStatusToXml(input BucketLoggingStatus, returnMd5 bool, isObs
grantsLength := len(input.TargetGrants)
xml := make([]string, 0, 8+grantsLength)

xml = append(xml, "<BucketLoggingStatus>")
if isObs {
xml = append(xml, "<BucketLoggingStatus>")
} else {
xml = append(xml, `<BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/">`)
}
if isObs && input.Agency != "" {
agency := XmlTranscoding(input.Agency)
xml = append(xml, fmt.Sprintf("<Agency>%s</Agency>", agency))
Expand Down
1 change: 1 addition & 0 deletions obs/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func WithCustomHeader(key string, value string) extensionHeaders {
if strings.TrimSpace(value) == "" {
return fmt.Errorf("set header %s with empty value", key)
}
allowedRequestHTTPHeaderMetadataNames[strings.ToLower(key)] = true
headers[key] = []string{value}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion obs/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (obsClient ObsClient) doAction(action, method, bucketName, objectKey string

for _, extension := range extensions {
if extensionHeader, ok := extension.(extensionHeaders); ok {
if _err := extensionHeader(headers, isObs); err != nil {
if _err := extensionHeader(headers, isObs); _err != nil {
doLog(LEVEL_INFO, fmt.Sprintf("set header with error: %v", _err))
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions obs/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,10 @@ func logResponseHeader(respHeader http.Header) string {
if key == "" {
continue
}
if strings.HasPrefix(key, HEADER_PREFIX) || strings.HasPrefix(key, HEADER_PREFIX_OBS) {
key = key[len(HEADER_PREFIX):]
}
_key := strings.ToLower(key)
if strings.HasPrefix(_key, HEADER_PREFIX) || strings.HasPrefix(_key, HEADER_PREFIX_OBS) {
_key = _key[len(HEADER_PREFIX):]
}
if _, ok := allowedLogResponseHTTPHeaderNames[_key]; ok {
resp = append(resp, fmt.Sprintf("%s: [%s]", key, value[0]))
}
Expand Down
16 changes: 12 additions & 4 deletions obs/model_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,20 @@ type CreateSignedUrlOutput struct {
ActualSignedRequestHeaders http.Header
}

// ConditionRange the specifying ranges in the conditions
type ConditionRange struct {
RangeName string
Lower int64
Upper int64
}

// CreateBrowserBasedSignatureInput is the input parameter of CreateBrowserBasedSignature function.
type CreateBrowserBasedSignatureInput struct {
Bucket string
Key string
Expires int
FormParams map[string]string
Bucket string
Key string
Expires int
FormParams map[string]string
RangeParams []ConditionRange
}

// CreateBrowserBasedSignatureOutput is the result of CreateBrowserBasedSignature function.
Expand Down
12 changes: 12 additions & 0 deletions obs/progress.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// Copyright 2019 Huawei Technologies Co.,Ltd.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
// License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.

package obs

import (
Expand Down
4 changes: 4 additions & 0 deletions obs/temporary_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ func (obsClient ObsClient) CreateBrowserBasedSignature(input *CreateBrowserBased
originPolicySlice = append(originPolicySlice, "[\"starts-with\", \"$key\", \"\"],")
}

for _, v := range input.RangeParams {
originPolicySlice = append(originPolicySlice, fmt.Sprintf("[\"%s\", %d, %d],", v.RangeName, v.Lower, v.Upper))
}

originPolicySlice = append(originPolicySlice, "]}")

originPolicy := strings.Join(originPolicySlice, "")
Expand Down

0 comments on commit 5105f9c

Please sign in to comment.