yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/huawei/obs/temporary.go (about)

     1  // Copyright 2019 Yunion
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // Copyright 2019 Huawei Technologies Co.,Ltd.
    16  // Licensed under the Apache License, Version 2.0 (the "License"); you may not use
    17  // this file except in compliance with the License.  You may obtain a copy of the
    18  // License at
    19  //
    20  // http://www.apache.org/licenses/LICENSE-2.0
    21  //
    22  // Unless required by applicable law or agreed to in writing, software distributed
    23  // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
    24  // CONDITIONS OF ANY KIND, either express or implied.  See the License for the
    25  // specific language governing permissions and limitations under the License.
    26  
    27  package obs
    28  
    29  import (
    30  	"errors"
    31  	"fmt"
    32  	"io"
    33  	"net/http"
    34  	"os"
    35  	"strings"
    36  	"time"
    37  )
    38  
    39  func (obsClient ObsClient) CreateSignedUrl(input *CreateSignedUrlInput) (output *CreateSignedUrlOutput, err error) {
    40  	if input == nil {
    41  		return nil, errors.New("CreateSignedUrlInput is nil")
    42  	}
    43  
    44  	params := make(map[string]string, len(input.QueryParams))
    45  	for key, value := range input.QueryParams {
    46  		params[key] = value
    47  	}
    48  
    49  	if input.SubResource != "" {
    50  		params[string(input.SubResource)] = ""
    51  	}
    52  
    53  	headers := make(map[string][]string, len(input.Headers))
    54  	for key, value := range input.Headers {
    55  		headers[key] = []string{value}
    56  	}
    57  
    58  	if input.Expires <= 0 {
    59  		input.Expires = 300
    60  	}
    61  
    62  	requestUrl, err := obsClient.doAuthTemporary(string(input.Method), input.Bucket, input.Key, params, headers, int64(input.Expires))
    63  	if err != nil {
    64  		return nil, err
    65  	}
    66  
    67  	output = &CreateSignedUrlOutput{
    68  		SignedUrl:                  requestUrl,
    69  		ActualSignedRequestHeaders: headers,
    70  	}
    71  	return
    72  }
    73  
    74  func (obsClient ObsClient) isSecurityToken(params map[string]string) {
    75  	if obsClient.conf.securityProvider.securityToken != "" {
    76  		if obsClient.conf.signature == SignatureObs {
    77  			params[HEADER_STS_TOKEN_OBS] = obsClient.conf.securityProvider.securityToken
    78  		} else {
    79  			params[HEADER_STS_TOKEN_AMZ] = obsClient.conf.securityProvider.securityToken
    80  		}
    81  	}
    82  }
    83  
    84  func (obsClient ObsClient) CreateBrowserBasedSignature(input *CreateBrowserBasedSignatureInput) (output *CreateBrowserBasedSignatureOutput, err error) {
    85  	if input == nil {
    86  		return nil, errors.New("CreateBrowserBasedSignatureInput is nil")
    87  	}
    88  
    89  	params := make(map[string]string, len(input.FormParams))
    90  	for key, value := range input.FormParams {
    91  		params[key] = value
    92  	}
    93  
    94  	date := time.Now().UTC()
    95  	shortDate := date.Format(SHORT_DATE_FORMAT)
    96  	longDate := date.Format(LONG_DATE_FORMAT)
    97  
    98  	credential, _ := getCredential(obsClient.conf.securityProvider.ak, obsClient.conf.region, shortDate)
    99  
   100  	if input.Expires <= 0 {
   101  		input.Expires = 300
   102  	}
   103  
   104  	expiration := date.Add(time.Second * time.Duration(input.Expires)).Format(ISO8601_DATE_FORMAT)
   105  	if obsClient.conf.signature == SignatureV4 {
   106  		params[PARAM_ALGORITHM_AMZ_CAMEL] = V4_HASH_PREFIX
   107  		params[PARAM_CREDENTIAL_AMZ_CAMEL] = credential
   108  		params[PARAM_DATE_AMZ_CAMEL] = longDate
   109  	}
   110  
   111  	obsClient.isSecurityToken(params)
   112  
   113  	matchAnyBucket := true
   114  	matchAnyKey := true
   115  	count := 5
   116  	if bucket := strings.TrimSpace(input.Bucket); bucket != "" {
   117  		params["bucket"] = bucket
   118  		matchAnyBucket = false
   119  		count--
   120  	}
   121  
   122  	if key := strings.TrimSpace(input.Key); key != "" {
   123  		params["key"] = key
   124  		matchAnyKey = false
   125  		count--
   126  	}
   127  
   128  	originPolicySlice := make([]string, 0, len(params)+count)
   129  	originPolicySlice = append(originPolicySlice, fmt.Sprintf("{\"expiration\":\"%s\",", expiration))
   130  	originPolicySlice = append(originPolicySlice, "\"conditions\":[")
   131  	for key, value := range params {
   132  		if _key := strings.TrimSpace(strings.ToLower(key)); _key != "" {
   133  			originPolicySlice = append(originPolicySlice, fmt.Sprintf("{\"%s\":\"%s\"},", _key, value))
   134  		}
   135  	}
   136  
   137  	if matchAnyBucket {
   138  		originPolicySlice = append(originPolicySlice, "[\"starts-with\", \"$bucket\", \"\"],")
   139  	}
   140  
   141  	if matchAnyKey {
   142  		originPolicySlice = append(originPolicySlice, "[\"starts-with\", \"$key\", \"\"],")
   143  	}
   144  
   145  	originPolicySlice = append(originPolicySlice, "]}")
   146  
   147  	originPolicy := strings.Join(originPolicySlice, "")
   148  	policy := Base64Encode([]byte(originPolicy))
   149  	var signature string
   150  	if obsClient.conf.signature == SignatureV4 {
   151  		signature = getSignature(policy, obsClient.conf.securityProvider.sk, obsClient.conf.region, shortDate)
   152  	} else {
   153  		signature = Base64Encode(HmacSha1([]byte(obsClient.conf.securityProvider.sk), []byte(policy)))
   154  	}
   155  
   156  	output = &CreateBrowserBasedSignatureOutput{
   157  		OriginPolicy: originPolicy,
   158  		Policy:       policy,
   159  		Algorithm:    params[PARAM_ALGORITHM_AMZ_CAMEL],
   160  		Credential:   params[PARAM_CREDENTIAL_AMZ_CAMEL],
   161  		Date:         params[PARAM_DATE_AMZ_CAMEL],
   162  		Signature:    signature,
   163  	}
   164  	return
   165  }
   166  
   167  func (obsClient ObsClient) ListBucketsWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *ListBucketsOutput, err error) {
   168  	output = &ListBucketsOutput{}
   169  	err = obsClient.doHttpWithSignedUrl("ListBuckets", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   170  	if err != nil {
   171  		output = nil
   172  	}
   173  	return
   174  }
   175  
   176  func (obsClient ObsClient) CreateBucketWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error) {
   177  	output = &BaseModel{}
   178  	err = obsClient.doHttpWithSignedUrl("CreateBucket", HTTP_PUT, signedUrl, actualSignedRequestHeaders, data, output, true)
   179  	if err != nil {
   180  		output = nil
   181  	}
   182  	return
   183  }
   184  
   185  func (obsClient ObsClient) DeleteBucketWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *BaseModel, err error) {
   186  	output = &BaseModel{}
   187  	err = obsClient.doHttpWithSignedUrl("DeleteBucket", HTTP_DELETE, signedUrl, actualSignedRequestHeaders, nil, output, true)
   188  	if err != nil {
   189  		output = nil
   190  	}
   191  	return
   192  }
   193  
   194  func (obsClient ObsClient) SetBucketStoragePolicyWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error) {
   195  	output = &BaseModel{}
   196  	err = obsClient.doHttpWithSignedUrl("SetBucketStoragePolicy", HTTP_PUT, signedUrl, actualSignedRequestHeaders, data, output, true)
   197  	if err != nil {
   198  		output = nil
   199  	}
   200  	return
   201  }
   202  
   203  func (obsClient ObsClient) GetBucketStoragePolicyWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketStoragePolicyOutput, err error) {
   204  	output = &GetBucketStoragePolicyOutput{}
   205  	err = obsClient.doHttpWithSignedUrl("GetBucketStoragePolicy", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   206  	if err != nil {
   207  		output = nil
   208  	}
   209  	return
   210  }
   211  
   212  func (obsClient ObsClient) ListObjectsWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *ListObjectsOutput, err error) {
   213  	output = &ListObjectsOutput{}
   214  	err = obsClient.doHttpWithSignedUrl("ListObjects", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   215  	if err != nil {
   216  		output = nil
   217  	} else {
   218  		if location, ok := output.ResponseHeaders[HEADER_BUCKET_REGION]; ok {
   219  			output.Location = location[0]
   220  		}
   221  	}
   222  	return
   223  }
   224  
   225  func (obsClient ObsClient) ListVersionsWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *ListVersionsOutput, err error) {
   226  	output = &ListVersionsOutput{}
   227  	err = obsClient.doHttpWithSignedUrl("ListVersions", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   228  	if err != nil {
   229  		output = nil
   230  	} else {
   231  		if location, ok := output.ResponseHeaders[HEADER_BUCKET_REGION]; ok {
   232  			output.Location = location[0]
   233  		}
   234  	}
   235  	return
   236  }
   237  
   238  func (obsClient ObsClient) ListMultipartUploadsWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *ListMultipartUploadsOutput, err error) {
   239  	output = &ListMultipartUploadsOutput{}
   240  	err = obsClient.doHttpWithSignedUrl("ListMultipartUploads", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   241  	if err != nil {
   242  		output = nil
   243  	}
   244  	return
   245  }
   246  
   247  func (obsClient ObsClient) SetBucketQuotaWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error) {
   248  	output = &BaseModel{}
   249  	err = obsClient.doHttpWithSignedUrl("SetBucketQuota", HTTP_PUT, signedUrl, actualSignedRequestHeaders, data, output, true)
   250  	if err != nil {
   251  		output = nil
   252  	}
   253  	return
   254  }
   255  
   256  func (obsClient ObsClient) GetBucketQuotaWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketQuotaOutput, err error) {
   257  	output = &GetBucketQuotaOutput{}
   258  	err = obsClient.doHttpWithSignedUrl("GetBucketQuota", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   259  	if err != nil {
   260  		output = nil
   261  	}
   262  	return
   263  }
   264  
   265  func (obsClient ObsClient) HeadBucketWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *BaseModel, err error) {
   266  	output = &BaseModel{}
   267  	err = obsClient.doHttpWithSignedUrl("HeadBucket", HTTP_HEAD, signedUrl, actualSignedRequestHeaders, nil, output, true)
   268  	if err != nil {
   269  		output = nil
   270  	}
   271  	return
   272  }
   273  
   274  func (obsClient ObsClient) GetBucketMetadataWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketMetadataOutput, err error) {
   275  	output = &GetBucketMetadataOutput{}
   276  	err = obsClient.doHttpWithSignedUrl("GetBucketMetadata", HTTP_HEAD, signedUrl, actualSignedRequestHeaders, nil, output, true)
   277  	if err != nil {
   278  		output = nil
   279  	} else {
   280  		ParseGetBucketMetadataOutput(output)
   281  	}
   282  	return
   283  }
   284  
   285  func (obsClient ObsClient) GetBucketStorageInfoWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketStorageInfoOutput, err error) {
   286  	output = &GetBucketStorageInfoOutput{}
   287  	err = obsClient.doHttpWithSignedUrl("GetBucketStorageInfo", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   288  	if err != nil {
   289  		output = nil
   290  	}
   291  	return
   292  }
   293  
   294  func (obsClient ObsClient) GetBucketLocationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketLocationOutput, err error) {
   295  	output = &GetBucketLocationOutput{}
   296  	err = obsClient.doHttpWithSignedUrl("GetBucketLocation", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   297  	if err != nil {
   298  		output = nil
   299  	}
   300  	return
   301  }
   302  
   303  func (obsClient ObsClient) SetBucketAclWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error) {
   304  	output = &BaseModel{}
   305  	err = obsClient.doHttpWithSignedUrl("SetBucketAcl", HTTP_PUT, signedUrl, actualSignedRequestHeaders, data, output, true)
   306  	if err != nil {
   307  		output = nil
   308  	}
   309  	return
   310  }
   311  
   312  func (obsClient ObsClient) GetBucketAclWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketAclOutput, err error) {
   313  	output = &GetBucketAclOutput{}
   314  	err = obsClient.doHttpWithSignedUrl("GetBucketAcl", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   315  	if err != nil {
   316  		output = nil
   317  	}
   318  	return
   319  }
   320  
   321  func (obsClient ObsClient) SetBucketPolicyWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error) {
   322  	output = &BaseModel{}
   323  	err = obsClient.doHttpWithSignedUrl("SetBucketPolicy", HTTP_PUT, signedUrl, actualSignedRequestHeaders, data, output, true)
   324  	if err != nil {
   325  		output = nil
   326  	}
   327  	return
   328  }
   329  
   330  func (obsClient ObsClient) GetBucketPolicyWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketPolicyOutput, err error) {
   331  	output = &GetBucketPolicyOutput{}
   332  	err = obsClient.doHttpWithSignedUrl("GetBucketPolicy", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, false)
   333  	if err != nil {
   334  		output = nil
   335  	}
   336  	return
   337  }
   338  
   339  func (obsClient ObsClient) DeleteBucketPolicyWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *BaseModel, err error) {
   340  	output = &BaseModel{}
   341  	err = obsClient.doHttpWithSignedUrl("DeleteBucketPolicy", HTTP_DELETE, signedUrl, actualSignedRequestHeaders, nil, output, true)
   342  	if err != nil {
   343  		output = nil
   344  	}
   345  	return
   346  }
   347  
   348  func (obsClient ObsClient) SetBucketCorsWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error) {
   349  	output = &BaseModel{}
   350  	err = obsClient.doHttpWithSignedUrl("SetBucketCors", HTTP_PUT, signedUrl, actualSignedRequestHeaders, data, output, true)
   351  	if err != nil {
   352  		output = nil
   353  	}
   354  	return
   355  }
   356  
   357  func (obsClient ObsClient) GetBucketCorsWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketCorsOutput, err error) {
   358  	output = &GetBucketCorsOutput{}
   359  	err = obsClient.doHttpWithSignedUrl("GetBucketCors", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   360  	if err != nil {
   361  		output = nil
   362  	}
   363  	return
   364  }
   365  
   366  func (obsClient ObsClient) DeleteBucketCorsWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *BaseModel, err error) {
   367  	output = &BaseModel{}
   368  	err = obsClient.doHttpWithSignedUrl("DeleteBucketCors", HTTP_DELETE, signedUrl, actualSignedRequestHeaders, nil, output, true)
   369  	if err != nil {
   370  		output = nil
   371  	}
   372  	return
   373  }
   374  
   375  func (obsClient ObsClient) SetBucketVersioningWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error) {
   376  	output = &BaseModel{}
   377  	err = obsClient.doHttpWithSignedUrl("SetBucketVersioning", HTTP_PUT, signedUrl, actualSignedRequestHeaders, data, output, true)
   378  	if err != nil {
   379  		output = nil
   380  	}
   381  	return
   382  }
   383  
   384  func (obsClient ObsClient) GetBucketVersioningWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketVersioningOutput, err error) {
   385  	output = &GetBucketVersioningOutput{}
   386  	err = obsClient.doHttpWithSignedUrl("GetBucketVersioning", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   387  	if err != nil {
   388  		output = nil
   389  	}
   390  	return
   391  }
   392  
   393  func (obsClient ObsClient) SetBucketWebsiteConfigurationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error) {
   394  	output = &BaseModel{}
   395  	err = obsClient.doHttpWithSignedUrl("SetBucketWebsiteConfiguration", HTTP_PUT, signedUrl, actualSignedRequestHeaders, data, output, true)
   396  	if err != nil {
   397  		output = nil
   398  	}
   399  	return
   400  }
   401  
   402  func (obsClient ObsClient) GetBucketWebsiteConfigurationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketWebsiteConfigurationOutput, err error) {
   403  	output = &GetBucketWebsiteConfigurationOutput{}
   404  	err = obsClient.doHttpWithSignedUrl("GetBucketWebsiteConfiguration", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   405  	if err != nil {
   406  		output = nil
   407  	}
   408  	return
   409  }
   410  
   411  func (obsClient ObsClient) DeleteBucketWebsiteConfigurationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *BaseModel, err error) {
   412  	output = &BaseModel{}
   413  	err = obsClient.doHttpWithSignedUrl("DeleteBucketWebsiteConfiguration", HTTP_DELETE, signedUrl, actualSignedRequestHeaders, nil, output, true)
   414  	if err != nil {
   415  		output = nil
   416  	}
   417  	return
   418  }
   419  
   420  func (obsClient ObsClient) SetBucketLoggingConfigurationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error) {
   421  	output = &BaseModel{}
   422  	err = obsClient.doHttpWithSignedUrl("SetBucketLoggingConfiguration", HTTP_PUT, signedUrl, actualSignedRequestHeaders, data, output, true)
   423  	if err != nil {
   424  		output = nil
   425  	}
   426  	return
   427  }
   428  
   429  func (obsClient ObsClient) GetBucketLoggingConfigurationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketLoggingConfigurationOutput, err error) {
   430  	output = &GetBucketLoggingConfigurationOutput{}
   431  	err = obsClient.doHttpWithSignedUrl("GetBucketLoggingConfiguration", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   432  	if err != nil {
   433  		output = nil
   434  	}
   435  	return
   436  }
   437  
   438  func (obsClient ObsClient) SetBucketLifecycleConfigurationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error) {
   439  	output = &BaseModel{}
   440  	err = obsClient.doHttpWithSignedUrl("SetBucketLifecycleConfiguration", HTTP_PUT, signedUrl, actualSignedRequestHeaders, data, output, true)
   441  	if err != nil {
   442  		output = nil
   443  	}
   444  	return
   445  }
   446  
   447  func (obsClient ObsClient) GetBucketLifecycleConfigurationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketLifecycleConfigurationOutput, err error) {
   448  	output = &GetBucketLifecycleConfigurationOutput{}
   449  	err = obsClient.doHttpWithSignedUrl("GetBucketLifecycleConfiguration", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   450  	if err != nil {
   451  		output = nil
   452  	}
   453  	return
   454  }
   455  
   456  func (obsClient ObsClient) DeleteBucketLifecycleConfigurationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *BaseModel, err error) {
   457  	output = &BaseModel{}
   458  	err = obsClient.doHttpWithSignedUrl("DeleteBucketLifecycleConfiguration", HTTP_DELETE, signedUrl, actualSignedRequestHeaders, nil, output, true)
   459  	if err != nil {
   460  		output = nil
   461  	}
   462  	return
   463  }
   464  
   465  func (obsClient ObsClient) SetBucketTaggingWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error) {
   466  	output = &BaseModel{}
   467  	err = obsClient.doHttpWithSignedUrl("SetBucketTagging", HTTP_PUT, signedUrl, actualSignedRequestHeaders, data, output, true)
   468  	if err != nil {
   469  		output = nil
   470  	}
   471  	return
   472  }
   473  
   474  func (obsClient ObsClient) GetBucketTaggingWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketTaggingOutput, err error) {
   475  	output = &GetBucketTaggingOutput{}
   476  	err = obsClient.doHttpWithSignedUrl("GetBucketTagging", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   477  	if err != nil {
   478  		output = nil
   479  	}
   480  	return
   481  }
   482  
   483  func (obsClient ObsClient) DeleteBucketTaggingWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *BaseModel, err error) {
   484  	output = &BaseModel{}
   485  	err = obsClient.doHttpWithSignedUrl("DeleteBucketTagging", HTTP_DELETE, signedUrl, actualSignedRequestHeaders, nil, output, true)
   486  	if err != nil {
   487  		output = nil
   488  	}
   489  	return
   490  }
   491  
   492  func (obsClient ObsClient) SetBucketNotificationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error) {
   493  	output = &BaseModel{}
   494  	err = obsClient.doHttpWithSignedUrl("SetBucketNotification", HTTP_PUT, signedUrl, actualSignedRequestHeaders, data, output, true)
   495  	if err != nil {
   496  		output = nil
   497  	}
   498  	return
   499  }
   500  
   501  func (obsClient ObsClient) GetBucketNotificationWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetBucketNotificationOutput, err error) {
   502  	output = &GetBucketNotificationOutput{}
   503  	err = obsClient.doHttpWithSignedUrl("GetBucketNotification", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   504  	if err != nil {
   505  		output = nil
   506  	}
   507  	return
   508  }
   509  
   510  func (obsClient ObsClient) DeleteObjectWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *DeleteObjectOutput, err error) {
   511  	output = &DeleteObjectOutput{}
   512  	err = obsClient.doHttpWithSignedUrl("DeleteObject", HTTP_DELETE, signedUrl, actualSignedRequestHeaders, nil, output, true)
   513  	if err != nil {
   514  		output = nil
   515  	} else {
   516  		ParseDeleteObjectOutput(output)
   517  	}
   518  	return
   519  }
   520  
   521  func (obsClient ObsClient) DeleteObjectsWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *DeleteObjectsOutput, err error) {
   522  	output = &DeleteObjectsOutput{}
   523  	err = obsClient.doHttpWithSignedUrl("DeleteObjects", HTTP_POST, signedUrl, actualSignedRequestHeaders, data, output, true)
   524  	if err != nil {
   525  		output = nil
   526  	}
   527  	return
   528  }
   529  
   530  func (obsClient ObsClient) SetObjectAclWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error) {
   531  	output = &BaseModel{}
   532  	err = obsClient.doHttpWithSignedUrl("SetObjectAcl", HTTP_PUT, signedUrl, actualSignedRequestHeaders, data, output, true)
   533  	if err != nil {
   534  		output = nil
   535  	}
   536  	return
   537  }
   538  
   539  func (obsClient ObsClient) GetObjectAclWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetObjectAclOutput, err error) {
   540  	output = &GetObjectAclOutput{}
   541  	err = obsClient.doHttpWithSignedUrl("GetObjectAcl", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   542  	if err != nil {
   543  		output = nil
   544  	} else {
   545  		if versionId, ok := output.ResponseHeaders[HEADER_VERSION_ID]; ok {
   546  			output.VersionId = versionId[0]
   547  		}
   548  	}
   549  	return
   550  }
   551  
   552  func (obsClient ObsClient) RestoreObjectWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *BaseModel, err error) {
   553  	output = &BaseModel{}
   554  	err = obsClient.doHttpWithSignedUrl("RestoreObject", HTTP_POST, signedUrl, actualSignedRequestHeaders, data, output, true)
   555  	if err != nil {
   556  		output = nil
   557  	}
   558  	return
   559  }
   560  
   561  func (obsClient ObsClient) GetObjectMetadataWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetObjectMetadataOutput, err error) {
   562  	output = &GetObjectMetadataOutput{}
   563  	err = obsClient.doHttpWithSignedUrl("GetObjectMetadata", HTTP_HEAD, signedUrl, actualSignedRequestHeaders, nil, output, true)
   564  	if err != nil {
   565  		output = nil
   566  	} else {
   567  		ParseGetObjectMetadataOutput(output)
   568  	}
   569  	return
   570  }
   571  
   572  func (obsClient ObsClient) GetObjectWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *GetObjectOutput, err error) {
   573  	output = &GetObjectOutput{}
   574  	err = obsClient.doHttpWithSignedUrl("GetObject", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   575  	if err != nil {
   576  		output = nil
   577  	} else {
   578  		ParseGetObjectOutput(output)
   579  	}
   580  	return
   581  }
   582  
   583  func (obsClient ObsClient) PutObjectWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *PutObjectOutput, err error) {
   584  	output = &PutObjectOutput{}
   585  	err = obsClient.doHttpWithSignedUrl("PutObject", HTTP_PUT, signedUrl, actualSignedRequestHeaders, data, output, true)
   586  	if err != nil {
   587  		output = nil
   588  	} else {
   589  		ParsePutObjectOutput(output)
   590  	}
   591  	return
   592  }
   593  
   594  func (obsClient ObsClient) PutFileWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, sourceFile string) (output *PutObjectOutput, err error) {
   595  	var data io.Reader
   596  	sourceFile = strings.TrimSpace(sourceFile)
   597  	if sourceFile != "" {
   598  		fd, _err := os.Open(sourceFile)
   599  		if _err != nil {
   600  			err = _err
   601  			return nil, err
   602  		}
   603  		defer func() {
   604  			errMsg := fd.Close()
   605  			if errMsg != nil {
   606  				doLog(LEVEL_WARN, "Failed to close file with reason: %v", errMsg)
   607  			}
   608  		}()
   609  
   610  		stat, _err := fd.Stat()
   611  		if _err != nil {
   612  			err = _err
   613  			return nil, err
   614  		}
   615  		fileReaderWrapper := &fileReaderWrapper{filePath: sourceFile}
   616  		fileReaderWrapper.reader = fd
   617  
   618  		var contentLength int64
   619  		if value, ok := actualSignedRequestHeaders[HEADER_CONTENT_LENGTH_CAMEL]; ok {
   620  			contentLength = StringToInt64(value[0], -1)
   621  		} else if value, ok := actualSignedRequestHeaders[HEADER_CONTENT_LENGTH]; ok {
   622  			contentLength = StringToInt64(value[0], -1)
   623  		} else {
   624  			contentLength = stat.Size()
   625  		}
   626  		if contentLength > stat.Size() {
   627  			return nil, errors.New("ContentLength is larger than fileSize")
   628  		}
   629  		fileReaderWrapper.totalCount = contentLength
   630  		data = fileReaderWrapper
   631  	}
   632  
   633  	output = &PutObjectOutput{}
   634  	err = obsClient.doHttpWithSignedUrl("PutObject", HTTP_PUT, signedUrl, actualSignedRequestHeaders, data, output, true)
   635  	if err != nil {
   636  		output = nil
   637  	} else {
   638  		ParsePutObjectOutput(output)
   639  	}
   640  	return
   641  }
   642  
   643  func (obsClient ObsClient) CopyObjectWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *CopyObjectOutput, err error) {
   644  	output = &CopyObjectOutput{}
   645  	err = obsClient.doHttpWithSignedUrl("CopyObject", HTTP_PUT, signedUrl, actualSignedRequestHeaders, nil, output, true)
   646  	if err != nil {
   647  		output = nil
   648  	} else {
   649  		ParseCopyObjectOutput(output)
   650  	}
   651  	return
   652  }
   653  
   654  func (obsClient ObsClient) AbortMultipartUploadWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *BaseModel, err error) {
   655  	output = &BaseModel{}
   656  	err = obsClient.doHttpWithSignedUrl("AbortMultipartUpload", HTTP_DELETE, signedUrl, actualSignedRequestHeaders, nil, output, true)
   657  	if err != nil {
   658  		output = nil
   659  	}
   660  	return
   661  }
   662  
   663  func (obsClient ObsClient) InitiateMultipartUploadWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *InitiateMultipartUploadOutput, err error) {
   664  	output = &InitiateMultipartUploadOutput{}
   665  	err = obsClient.doHttpWithSignedUrl("InitiateMultipartUpload", HTTP_POST, signedUrl, actualSignedRequestHeaders, nil, output, true)
   666  	if err != nil {
   667  		output = nil
   668  	} else {
   669  		ParseInitiateMultipartUploadOutput(output)
   670  	}
   671  	return
   672  }
   673  
   674  func (obsClient ObsClient) UploadPartWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *UploadPartOutput, err error) {
   675  	output = &UploadPartOutput{}
   676  	err = obsClient.doHttpWithSignedUrl("UploadPart", HTTP_PUT, signedUrl, actualSignedRequestHeaders, data, output, true)
   677  	if err != nil {
   678  		output = nil
   679  	} else {
   680  		ParseUploadPartOutput(output)
   681  	}
   682  	return
   683  }
   684  
   685  func (obsClient ObsClient) CompleteMultipartUploadWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header, data io.Reader) (output *CompleteMultipartUploadOutput, err error) {
   686  	output = &CompleteMultipartUploadOutput{}
   687  	err = obsClient.doHttpWithSignedUrl("CompleteMultipartUpload", HTTP_POST, signedUrl, actualSignedRequestHeaders, data, output, true)
   688  	if err != nil {
   689  		output = nil
   690  	} else {
   691  		ParseCompleteMultipartUploadOutput(output)
   692  	}
   693  	return
   694  }
   695  
   696  func (obsClient ObsClient) ListPartsWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *ListPartsOutput, err error) {
   697  	output = &ListPartsOutput{}
   698  	err = obsClient.doHttpWithSignedUrl("ListParts", HTTP_GET, signedUrl, actualSignedRequestHeaders, nil, output, true)
   699  	if err != nil {
   700  		output = nil
   701  	}
   702  	return
   703  }
   704  
   705  func (obsClient ObsClient) CopyPartWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *CopyPartOutput, err error) {
   706  	output = &CopyPartOutput{}
   707  	err = obsClient.doHttpWithSignedUrl("CopyPart", HTTP_PUT, signedUrl, actualSignedRequestHeaders, nil, output, true)
   708  	if err != nil {
   709  		output = nil
   710  	} else {
   711  		ParseCopyPartOutput(output)
   712  	}
   713  	return
   714  }