1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package s3 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 s3cust "github.com/aws/aws-sdk-go-v2/service/s3/internal/customizations" 10 "github.com/aws/aws-sdk-go-v2/service/s3/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13 "time" 14) 15 16// Uploads a part by copying data from an existing object as data source. You 17// specify the data source by adding the request header x-amz-copy-source in your 18// request and a byte range by adding the request header x-amz-copy-source-range in 19// your request. The minimum allowable part size for a multipart upload is 5 MB. 20// For more information about multipart upload limits, go to Quick Facts 21// (https://docs.aws.amazon.com/AmazonS3/latest/dev/qfacts.html) in the Amazon S3 22// User Guide. Instead of using an existing object as part data, you might use the 23// UploadPart (https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html) 24// action and provide data in your request. You must initiate a multipart upload 25// before you can upload any part. In response to your initiate request. Amazon S3 26// returns a unique identifier, the upload ID, that you must include in your upload 27// part request. For more information about using the UploadPartCopy operation, see 28// the following: 29// 30// * For conceptual information about multipart uploads, see 31// Uploading Objects Using Multipart Upload 32// (https://docs.aws.amazon.com/AmazonS3/latest/dev/uploadobjusingmpu.html) in the 33// Amazon S3 User Guide. 34// 35// * For information about permissions required to use the 36// multipart upload API, see Multipart Upload and Permissions 37// (https://docs.aws.amazon.com/AmazonS3/latest/dev/mpuAndPermissions.html) in the 38// Amazon S3 User Guide. 39// 40// * For information about copying objects using a single 41// atomic action vs. the multipart upload, see Operations on Objects 42// (https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectOperations.html) in the 43// Amazon S3 User Guide. 44// 45// * For information about using server-side encryption with 46// customer-provided encryption keys with the UploadPartCopy operation, see 47// CopyObject (https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html) 48// and UploadPart 49// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html). 50// 51// Note the 52// following additional considerations about the request headers 53// x-amz-copy-source-if-match, x-amz-copy-source-if-none-match, 54// x-amz-copy-source-if-unmodified-since, and 55// x-amz-copy-source-if-modified-since: 56// 57// * Consideration 1 - If both of the 58// x-amz-copy-source-if-match and x-amz-copy-source-if-unmodified-since headers are 59// present in the request as follows: x-amz-copy-source-if-match condition 60// evaluates to true, and; x-amz-copy-source-if-unmodified-since condition 61// evaluates to false; Amazon S3 returns 200 OK and copies the data. 62// 63// * 64// Consideration 2 - If both of the x-amz-copy-source-if-none-match and 65// x-amz-copy-source-if-modified-since headers are present in the request as 66// follows: x-amz-copy-source-if-none-match condition evaluates to false, and; 67// x-amz-copy-source-if-modified-since condition evaluates to true; Amazon S3 68// returns 412 Precondition Failed response code. 69// 70// Versioning If your bucket has 71// versioning enabled, you could have multiple versions of the same object. By 72// default, x-amz-copy-source identifies the current version of the object to copy. 73// If the current version is a delete marker and you don't specify a versionId in 74// the x-amz-copy-source, Amazon S3 returns a 404 error, because the object does 75// not exist. If you specify versionId in the x-amz-copy-source and the versionId 76// is a delete marker, Amazon S3 returns an HTTP 400 error, because you are not 77// allowed to specify a delete marker as a version for the x-amz-copy-source. You 78// can optionally specify a specific version of the source object to copy by adding 79// the versionId subresource as shown in the following example: x-amz-copy-source: 80// /bucket/object?versionId=version id Special Errors 81// 82// * Code: NoSuchUpload 83// 84// * 85// Cause: The specified multipart upload does not exist. The upload ID might be 86// invalid, or the multipart upload might have been aborted or completed. 87// 88// * HTTP 89// Status Code: 404 Not Found 90// 91// * Code: InvalidRequest 92// 93// * Cause: The specified copy 94// source is not supported as a byte-range copy source. 95// 96// * HTTP Status Code: 400 97// Bad Request 98// 99// Related Resources 100// 101// * CreateMultipartUpload 102// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html) 103// 104// * 105// UploadPart 106// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html) 107// 108// * 109// CompleteMultipartUpload 110// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html) 111// 112// * 113// AbortMultipartUpload 114// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_AbortMultipartUpload.html) 115// 116// * 117// ListParts 118// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html) 119// 120// * 121// ListMultipartUploads 122// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html) 123func (c *Client) UploadPartCopy(ctx context.Context, params *UploadPartCopyInput, optFns ...func(*Options)) (*UploadPartCopyOutput, error) { 124 if params == nil { 125 params = &UploadPartCopyInput{} 126 } 127 128 result, metadata, err := c.invokeOperation(ctx, "UploadPartCopy", params, optFns, addOperationUploadPartCopyMiddlewares) 129 if err != nil { 130 return nil, err 131 } 132 133 out := result.(*UploadPartCopyOutput) 134 out.ResultMetadata = metadata 135 return out, nil 136} 137 138type UploadPartCopyInput struct { 139 140 // The bucket name. When using this action with an access point, you must direct 141 // requests to the access point hostname. The access point hostname takes the form 142 // AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this 143 // action with an access point through the AWS SDKs, you provide the access point 144 // ARN in place of the bucket name. For more information about access point ARNs, 145 // see Using Access Points 146 // (https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html) 147 // in the Amazon S3 User Guide. When using this action with Amazon S3 on Outposts, 148 // you must direct requests to the S3 on Outposts hostname. The S3 on Outposts 149 // hostname takes the form 150 // AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using 151 // this action using S3 on Outposts through the AWS SDKs, you provide the Outposts 152 // bucket ARN in place of the bucket name. For more information about S3 on 153 // Outposts ARNs, see Using S3 on Outposts 154 // (https://docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html) in the 155 // Amazon S3 User Guide. 156 // 157 // This member is required. 158 Bucket *string 159 160 // Specifies the source object for the copy operation. You specify the value in one 161 // of two formats, depending on whether you want to access the source object 162 // through an access point 163 // (https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-points.html): 164 // 165 // * 166 // For objects not accessed through an access point, specify the name of the source 167 // bucket and key of the source object, separated by a slash (/). For example, to 168 // copy the object reports/january.pdf from the bucket awsexamplebucket, use 169 // awsexamplebucket/reports/january.pdf. The value must be URL encoded. 170 // 171 // * For 172 // objects accessed through access points, specify the Amazon Resource Name (ARN) 173 // of the object as accessed through the access point, in the format 174 // arn:aws:s3:::accesspoint//object/. For example, to copy the object 175 // reports/january.pdf through access point my-access-point owned by account 176 // 123456789012 in Region us-west-2, use the URL encoding of 177 // arn:aws:s3:us-west-2:123456789012:accesspoint/my-access-point/object/reports/january.pdf. 178 // The value must be URL encoded. Amazon S3 supports copy operations using access 179 // points only when the source and destination buckets are in the same AWS Region. 180 // Alternatively, for objects accessed through Amazon S3 on Outposts, specify the 181 // ARN of the object as accessed in the format 182 // arn:aws:s3-outposts:::outpost//object/. For example, to copy the object 183 // reports/january.pdf through outpost my-outpost owned by account 123456789012 in 184 // Region us-west-2, use the URL encoding of 185 // arn:aws:s3-outposts:us-west-2:123456789012:outpost/my-outpost/object/reports/january.pdf. 186 // The value must be URL encoded. 187 // 188 // To copy a specific version of an object, append 189 // ?versionId= to the value (for example, 190 // awsexamplebucket/reports/january.pdf?versionId=QUpfdndhfd8438MNFDN93jdnJFkdmqnh893). 191 // If you don't specify a version ID, Amazon S3 copies the latest version of the 192 // source object. 193 // 194 // This member is required. 195 CopySource *string 196 197 // Object key for which the multipart upload was initiated. 198 // 199 // This member is required. 200 Key *string 201 202 // Part number of part being copied. This is a positive integer between 1 and 203 // 10,000. 204 // 205 // This member is required. 206 PartNumber int32 207 208 // Upload ID identifying the multipart upload whose part is being copied. 209 // 210 // This member is required. 211 UploadId *string 212 213 // Copies the object if its entity tag (ETag) matches the specified tag. 214 CopySourceIfMatch *string 215 216 // Copies the object if it has been modified since the specified time. 217 CopySourceIfModifiedSince *time.Time 218 219 // Copies the object if its entity tag (ETag) is different than the specified ETag. 220 CopySourceIfNoneMatch *string 221 222 // Copies the object if it hasn't been modified since the specified time. 223 CopySourceIfUnmodifiedSince *time.Time 224 225 // The range of bytes to copy from the source object. The range value must use the 226 // form bytes=first-last, where the first and last are the zero-based byte offsets 227 // to copy. For example, bytes=0-9 indicates that you want to copy the first 10 228 // bytes of the source. You can copy a range only if the source object is greater 229 // than 5 MB. 230 CopySourceRange *string 231 232 // Specifies the algorithm to use when decrypting the source object (for example, 233 // AES256). 234 CopySourceSSECustomerAlgorithm *string 235 236 // Specifies the customer-provided encryption key for Amazon S3 to use to decrypt 237 // the source object. The encryption key provided in this header must be one that 238 // was used when the source object was created. 239 CopySourceSSECustomerKey *string 240 241 // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. 242 // Amazon S3 uses this header for a message integrity check to ensure that the 243 // encryption key was transmitted without error. 244 CopySourceSSECustomerKeyMD5 *string 245 246 // The account ID of the expected destination bucket owner. If the destination 247 // bucket is owned by a different account, the request will fail with an HTTP 403 248 // (Access Denied) error. 249 ExpectedBucketOwner *string 250 251 // The account ID of the expected source bucket owner. If the source bucket is 252 // owned by a different account, the request will fail with an HTTP 403 (Access 253 // Denied) error. 254 ExpectedSourceBucketOwner *string 255 256 // Confirms that the requester knows that they will be charged for the request. 257 // Bucket owners need not specify this parameter in their requests. For information 258 // about downloading objects from requester pays buckets, see Downloading Objects 259 // in Requestor Pays Buckets 260 // (https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html) 261 // in the Amazon S3 Developer Guide. 262 RequestPayer types.RequestPayer 263 264 // Specifies the algorithm to use to when encrypting the object (for example, 265 // AES256). 266 SSECustomerAlgorithm *string 267 268 // Specifies the customer-provided encryption key for Amazon S3 to use in 269 // encrypting data. This value is used to store the object and then it is 270 // discarded; Amazon S3 does not store the encryption key. The key must be 271 // appropriate for use with the algorithm specified in the 272 // x-amz-server-side-encryption-customer-algorithm header. This must be the same 273 // encryption key specified in the initiate multipart upload request. 274 SSECustomerKey *string 275 276 // Specifies the 128-bit MD5 digest of the encryption key according to RFC 1321. 277 // Amazon S3 uses this header for a message integrity check to ensure that the 278 // encryption key was transmitted without error. 279 SSECustomerKeyMD5 *string 280} 281 282type UploadPartCopyOutput struct { 283 284 // Indicates whether the multipart upload uses an S3 Bucket Key for server-side 285 // encryption with AWS KMS (SSE-KMS). 286 BucketKeyEnabled bool 287 288 // Container for all response elements. 289 CopyPartResult *types.CopyPartResult 290 291 // The version of the source object that was copied, if you have enabled versioning 292 // on the source bucket. 293 CopySourceVersionId *string 294 295 // If present, indicates that the requester was successfully charged for the 296 // request. 297 RequestCharged types.RequestCharged 298 299 // If server-side encryption with a customer-provided encryption key was requested, 300 // the response will include this header confirming the encryption algorithm used. 301 SSECustomerAlgorithm *string 302 303 // If server-side encryption with a customer-provided encryption key was requested, 304 // the response will include this header to provide round-trip message integrity 305 // verification of the customer-provided encryption key. 306 SSECustomerKeyMD5 *string 307 308 // If present, specifies the ID of the AWS Key Management Service (AWS KMS) 309 // symmetric customer managed customer master key (CMK) that was used for the 310 // object. 311 SSEKMSKeyId *string 312 313 // The server-side encryption algorithm used when storing this object in Amazon S3 314 // (for example, AES256, aws:kms). 315 ServerSideEncryption types.ServerSideEncryption 316 317 // Metadata pertaining to the operation's result. 318 ResultMetadata middleware.Metadata 319} 320 321func addOperationUploadPartCopyMiddlewares(stack *middleware.Stack, options Options) (err error) { 322 err = stack.Serialize.Add(&awsRestxml_serializeOpUploadPartCopy{}, middleware.After) 323 if err != nil { 324 return err 325 } 326 err = stack.Deserialize.Add(&awsRestxml_deserializeOpUploadPartCopy{}, middleware.After) 327 if err != nil { 328 return err 329 } 330 if err = addSetLoggerMiddleware(stack, options); err != nil { 331 return err 332 } 333 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 334 return err 335 } 336 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 337 return err 338 } 339 if err = addResolveEndpointMiddleware(stack, options); err != nil { 340 return err 341 } 342 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 343 return err 344 } 345 if err = addRetryMiddlewares(stack, options); err != nil { 346 return err 347 } 348 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 349 return err 350 } 351 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 352 return err 353 } 354 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 355 return err 356 } 357 if err = addClientUserAgent(stack); err != nil { 358 return err 359 } 360 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 361 return err 362 } 363 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 364 return err 365 } 366 if err = addOpUploadPartCopyValidationMiddleware(stack); err != nil { 367 return err 368 } 369 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUploadPartCopy(options.Region), middleware.Before); err != nil { 370 return err 371 } 372 if err = addMetadataRetrieverMiddleware(stack); err != nil { 373 return err 374 } 375 if err = addUploadPartCopyUpdateEndpoint(stack, options); err != nil { 376 return err 377 } 378 if err = addResponseErrorMiddleware(stack); err != nil { 379 return err 380 } 381 if err = v4.AddContentSHA256HeaderMiddleware(stack); err != nil { 382 return err 383 } 384 if err = disableAcceptEncodingGzip(stack); err != nil { 385 return err 386 } 387 if err = s3cust.HandleResponseErrorWith200Status(stack); err != nil { 388 return err 389 } 390 if err = addRequestResponseLogging(stack, options); err != nil { 391 return err 392 } 393 return nil 394} 395 396func newServiceMetadataMiddleware_opUploadPartCopy(region string) *awsmiddleware.RegisterServiceMetadata { 397 return &awsmiddleware.RegisterServiceMetadata{ 398 Region: region, 399 ServiceID: ServiceID, 400 SigningName: "s3", 401 OperationName: "UploadPartCopy", 402 } 403} 404 405// getUploadPartCopyBucketMember returns a pointer to string denoting a provided 406// bucket member valueand a boolean indicating if the input has a modeled bucket 407// name, 408func getUploadPartCopyBucketMember(input interface{}) (*string, bool) { 409 in := input.(*UploadPartCopyInput) 410 if in.Bucket == nil { 411 return nil, false 412 } 413 return in.Bucket, true 414} 415func addUploadPartCopyUpdateEndpoint(stack *middleware.Stack, options Options) error { 416 return s3cust.UpdateEndpoint(stack, s3cust.UpdateEndpointOptions{ 417 Accessor: s3cust.UpdateEndpointParameterAccessor{ 418 GetBucketFromInput: getUploadPartCopyBucketMember, 419 }, 420 UsePathStyle: options.UsePathStyle, 421 UseAccelerate: options.UseAccelerate, 422 SupportsAccelerate: true, 423 TargetS3ObjectLambda: false, 424 EndpointResolver: options.EndpointResolver, 425 EndpointResolverOptions: options.EndpointOptions, 426 UseDualstack: options.UseDualstack, 427 UseARNRegion: options.UseARNRegion, 428 }) 429} 430