Skip to content

Commit

Permalink
分片复制,去掉一些无用头部
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Nov 25, 2019
1 parent 3286a50 commit 4a6ffee
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/advance.js
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,26 @@ function sliceCopyFile(params, callback) {
}
TargetHeader['x-cos-storage-class'] = params.Headers['x-cos-storage-class'] || SourceHeaders['x-cos-storage-class'];
TargetHeader = util.clearKey(TargetHeader);
/**
* 对于归档存储的对象,如果未恢复副本,则不允许 Copy
*/
if (SourceHeaders['x-cos-storage-class'] === 'ARCHIVE') {
var restoreHeader = SourceHeaders['x-cos-restore'];
if (!restoreHeader || restoreHeader === 'ongoing-request="true"') {
callback({ error: 'Unrestored archive object is not allowed to be copied' });
return;
}
}
/**
* 去除一些无用的头部,规避 multipartInit 出错
* 这些头部通常是在 putObjectCopy 时才使用
*/
delete TargetHeader['x-cos-copy-source'];
delete TargetHeader['x-cos-metadata-directive'];
delete TargetHeader['x-cos-copy-source-If-Modified-Since'];
delete TargetHeader['x-cos-copy-source-If-Unmodified-Since'];
delete TargetHeader['x-cos-copy-source-If-Match'];
delete TargetHeader['x-cos-copy-source-If-None-Match'];
self.multipartInit({
Bucket: Bucket,
Region: Region,
Expand Down

0 comments on commit 4a6ffee

Please sign in to comment.