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