Skip to content

Commit

Permalink
CORS 例子补充 ExposeHeaders Date
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonxu committed Dec 21, 2018
1 parent b090acc commit 5b92012
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var cos = new COS({
// xhr.send(JSON.stringify(options.Scope));


// // 方法三、后端使用固定密钥计算签名,返回给前端,auth.php,注意:后端需要通过 method、pathname 控制好权限,比如不允许 put / 等,这里暂不提供
// // 方法三、后端使用固定密钥计算签名,返回给前端,auth.php,注意:这种有安全风险,后端需要通过 method、pathname 控制好权限,比如不允许 put / 等,这里暂不提供
// var method = (options.Method || 'get').toLowerCase();
// var key = options.Key || '';
// var query = options.Query || {};
Expand Down Expand Up @@ -262,7 +262,7 @@ function putBucketCors() {
"AllowedOrigin": ["*"],
"AllowedMethod": ["GET", "POST", "PUT", "DELETE", "HEAD"],
"AllowedHeader": ["*"],
"ExposeHeader": ["ETag", "Content-Length", "x-cos-acl", "x-cos-version-id", "x-cos-delete-marker", "x-cos-server-side-encryption"],
"ExposeHeader": ["ETag", "Date", "Content-Length", "x-cos-acl", "x-cos-version-id", "x-cos-delete-marker", "x-cos-server-side-encryption"],
"MaxAgeSeconds": "5"
}]
}
Expand Down
13 changes: 10 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ group('mock readAsBinaryString', function () {
onProgress: function (info) {
if (!paused && info.percent > 0.6) {
cos.cancelTask(TaskId);
var hasProgress = false;
cos.sliceUploadFile({
Bucket: config.Bucket,
Region: config.Region,
Expand All @@ -237,6 +238,11 @@ group('mock readAsBinaryString', function () {
delete FileReader.prototype._readAsBinaryString;
done();
}
}, function (err) {
if (hasProgress) {
assert.ok(false, '分片续传');
done();
}
});
}
}
Expand Down Expand Up @@ -273,6 +279,7 @@ group('getAuth()', function () {
SecretKey: AuthData.TmpSecretKey,
Method: 'get',
Key: key,
SystemClockOffset: cos.options.SystemClockOffset,
});
}
var link = 'http://' + config.Bucket + '.cos.' + config.Region + '.myqcloud.com' + '/' +
Expand Down Expand Up @@ -1304,20 +1311,20 @@ group('BucketCors', function () {
"AllowedOrigins": ["*"],
"AllowedMethods": ["GET", "POST", "PUT", "DELETE", "HEAD"],
"AllowedHeaders": ["*", 'test-' + Date.now().toString(36)],
"ExposeHeaders": ["ETag", "Content-Length", "x-cos-acl", "x-cos-version-id", "x-cos-request-id", "x-cos-delete-marker", "x-cos-server-side-encryption"],
"ExposeHeaders": ["ETag", "Date", "Content-Length", "x-cos-acl", "x-cos-version-id", "x-cos-request-id", "x-cos-delete-marker", "x-cos-server-side-encryption"],
"MaxAgeSeconds": "5"
}];
var CORSRulesMulti = [{
"AllowedOrigins": ["*"],
"AllowedMethods": ["GET", "POST", "PUT", "DELETE", "HEAD"],
"AllowedHeaders": ["*"],
"ExposeHeaders": ["ETag", "Content-Length", "x-cos-acl", "x-cos-version-id", "x-cos-request-id", "x-cos-delete-marker", "x-cos-server-side-encryption"],
"ExposeHeaders": ["ETag", "Date", "Content-Length", "x-cos-acl", "x-cos-version-id", "x-cos-request-id", "x-cos-delete-marker", "x-cos-server-side-encryption"],
"MaxAgeSeconds": "5"
}, {
"AllowedOrigins": ["http://qq.com", "http://qcloud.com"],
"AllowedMethods": ["GET", "POST", "PUT", "DELETE", "HEAD"],
"AllowedHeaders": ["*"],
"ExposeHeaders": ["ETag", "Content-Length", "x-cos-acl", "x-cos-version-id", "x-cos-request-id", "x-cos-delete-marker", "x-cos-server-side-encryption"],
"ExposeHeaders": ["ETag", "Date", "Content-Length", "x-cos-acl", "x-cos-version-id", "x-cos-request-id", "x-cos-delete-marker", "x-cos-server-side-encryption"],
"MaxAgeSeconds": "5"
}];
test('putBucketCors(),getBucketCors()', function (done, assert) {
Expand Down

0 comments on commit 5b92012

Please sign in to comment.