mirror of
https://github.com/rclone/rclone.git
synced 2025-12-16 00:04:40 +00:00
s3: add multi-part-upload support for If-Match and If-None-Match
#8947 implemented support for the If-Match and If-None-Match headers for S3 PUT Object requests; however, this support did not extend to multi-part copy and upload requests. These headers are implemented via inclusion in the CompleteMultipartUpload request. This updates the auto generated code also which was needed for multipart copy.
This commit is contained in:
@@ -2835,6 +2835,8 @@ func (f *Fs) copyMultipart(ctx context.Context, copyReq *s3.CopyObjectInput, dst
|
||||
SSECustomerKey: req.SSECustomerKey,
|
||||
SSECustomerKeyMD5: req.SSECustomerKeyMD5,
|
||||
UploadId: uid,
|
||||
IfMatch: copyReq.IfMatch,
|
||||
IfNoneMatch: copyReq.IfNoneMatch,
|
||||
})
|
||||
return f.shouldRetry(ctx, err)
|
||||
})
|
||||
@@ -2869,13 +2871,20 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object,
|
||||
MetadataDirective: types.MetadataDirectiveCopy,
|
||||
}
|
||||
|
||||
// Update the metadata if it is in use
|
||||
if ci := fs.GetConfig(ctx); ci.Metadata {
|
||||
ui, err := srcObj.prepareUpload(ctx, src, fs.MetadataAsOpenOptions(ctx), true)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to prepare upload: %w", err)
|
||||
}
|
||||
setFrom_s3CopyObjectInput_s3PutObjectInput(&req, ui.req)
|
||||
// Build upload options including headers and metadata
|
||||
ci := fs.GetConfig(ctx)
|
||||
uploadOptions := fs.MetadataAsOpenOptions(ctx)
|
||||
for _, option := range ci.UploadHeaders {
|
||||
uploadOptions = append(uploadOptions, option)
|
||||
}
|
||||
|
||||
ui, err := srcObj.prepareUpload(ctx, src, uploadOptions, true)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to prepare upload: %w", err)
|
||||
}
|
||||
|
||||
setFrom_s3CopyObjectInput_s3PutObjectInput(&req, ui.req)
|
||||
if ci.Metadata {
|
||||
req.MetadataDirective = types.MetadataDirectiveReplace
|
||||
}
|
||||
|
||||
@@ -4284,6 +4293,8 @@ func (w *s3ChunkWriter) Close(ctx context.Context) (err error) {
|
||||
SSECustomerKey: w.multiPartUploadInput.SSECustomerKey,
|
||||
SSECustomerKeyMD5: w.multiPartUploadInput.SSECustomerKeyMD5,
|
||||
UploadId: w.uploadID,
|
||||
IfMatch: w.ui.req.IfMatch,
|
||||
IfNoneMatch: w.ui.req.IfNoneMatch,
|
||||
})
|
||||
return w.f.shouldRetry(ctx, err)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user