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