Skip to content

Commit 893dde3

Browse files
author
carsonxu
committed
分片上传支持 x-cos-meta 传递给 complete 接口
1 parent e38e060 commit 893dde3

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

dist/cos-js-sdk-v5.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -2161,7 +2161,7 @@ base.init(COS, task);
21612161
advance.init(COS, task);
21622162

21632163
COS.getAuthorization = util.getAuth;
2164-
COS.version = '1.1.1';
2164+
COS.version = '1.1.2';
21652165

21662166
module.exports = COS;
21672167

@@ -8362,12 +8362,17 @@ function sliceUploadFile(params, callback) {
83628362

83638363
// 上传分块完成,开始 uploadSliceComplete 操作
83648364
ep.on('upload_slice_complete', function (UploadData) {
8365+
var metaHeaders = {};
8366+
util.each(params.Headers, function (val, k) {
8367+
if (k.toLowerCase().indexOf('x-cos-meta-') === 0) metaHeaders[k] = val;
8368+
});
83658369
uploadSliceComplete.call(self, {
83668370
Bucket: Bucket,
83678371
Region: Region,
83688372
Key: Key,
83698373
UploadId: UploadData.UploadId,
8370-
SliceList: UploadData.SliceList
8374+
SliceList: UploadData.SliceList,
8375+
Headers: metaHeaders
83718376
}, function (err, data) {
83728377
if (!self._isRunningTask(TaskId)) return;
83738378
session.removeUsing(UploadData.UploadId);
@@ -8955,6 +8960,7 @@ function uploadSliceComplete(params, callback) {
89558960
var SliceList = params.SliceList;
89568961
var self = this;
89578962
var ChunkRetryTimes = this.options.ChunkRetryTimes + 1;
8963+
var Headers = params.Headers;
89588964
var Parts = SliceList.map(function (item) {
89598965
return {
89608966
PartNumber: item.PartNumber,
@@ -8968,7 +8974,8 @@ function uploadSliceComplete(params, callback) {
89688974
Region: Region,
89698975
Key: Key,
89708976
UploadId: UploadId,
8971-
Parts: Parts
8977+
Parts: Parts,
8978+
Headers: Headers
89728979
}, tryCallback);
89738980
}, function (err, data) {
89748981
callback(err, data);
@@ -9233,6 +9240,10 @@ function sliceCopyFile(params, callback) {
92339240

92349241
// 分片复制完成,开始 multipartComplete 操作
92359242
ep.on('copy_slice_complete', function (UploadData) {
9243+
var metaHeaders = {};
9244+
util.each(params.Headers, function (val, k) {
9245+
if (k.toLowerCase().indexOf('x-cos-meta-') === 0) metaHeaders[k] = val;
9246+
});
92369247
self.multipartComplete({
92379248
Bucket: Bucket,
92389249
Region: Region,

dist/cos-js-sdk-v5.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cos-js-sdk-v5",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "JavaScript SDK for [腾讯云对象存储](https://cloud.tencent.com/product/cos)",
55
"main": "index.js",
66
"scripts": {

src/advance.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,17 @@ function sliceUploadFile(params, callback) {
3434

3535
// 上传分块完成,开始 uploadSliceComplete 操作
3636
ep.on('upload_slice_complete', function (UploadData) {
37+
var metaHeaders = {};
38+
util.each(params.Headers, function (val, k) {
39+
if (k.toLowerCase().indexOf('x-cos-meta-') === 0) metaHeaders[k] = val;
40+
});
3741
uploadSliceComplete.call(self, {
3842
Bucket: Bucket,
3943
Region: Region,
4044
Key: Key,
4145
UploadId: UploadData.UploadId,
4246
SliceList: UploadData.SliceList,
47+
Headers: metaHeaders,
4348
}, function (err, data) {
4449
if (!self._isRunningTask(TaskId)) return;
4550
session.removeUsing(UploadData.UploadId);
@@ -627,6 +632,7 @@ function uploadSliceComplete(params, callback) {
627632
var SliceList = params.SliceList;
628633
var self = this;
629634
var ChunkRetryTimes = this.options.ChunkRetryTimes + 1;
635+
var Headers = params.Headers;
630636
var Parts = SliceList.map(function (item) {
631637
return {
632638
PartNumber: item.PartNumber,
@@ -640,7 +646,8 @@ function uploadSliceComplete(params, callback) {
640646
Region: Region,
641647
Key: Key,
642648
UploadId: UploadId,
643-
Parts: Parts
649+
Parts: Parts,
650+
Headers: Headers,
644651
}, tryCallback);
645652
}, function (err, data) {
646653
callback(err, data);
@@ -905,7 +912,10 @@ function sliceCopyFile(params, callback) {
905912
var onProgress;
906913

907914
// 分片复制完成,开始 multipartComplete 操作
908-
ep.on('copy_slice_complete', function (UploadData) {
915+
ep.on('copy_slice_complete', function (UploadData) {var metaHeaders = {};
916+
util.each(params.Headers, function (val, k) {
917+
if (k.toLowerCase().indexOf('x-cos-meta-') === 0) metaHeaders[k] = val;
918+
});
909919
self.multipartComplete({
910920
Bucket: Bucket,
911921
Region: Region,

src/cos.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ base.init(COS, task);
5959
advance.init(COS, task);
6060

6161
COS.getAuthorization = util.getAuth;
62-
COS.version = '1.1.1';
62+
COS.version = '1.1.2';
6363

6464
module.exports = COS;

0 commit comments

Comments
 (0)