Skip to content

Commit

Permalink
support SSE
Browse files Browse the repository at this point in the history
  • Loading branch information
tinnazhang committed Feb 2, 2018
1 parent b4d8df1 commit fb99f7c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 36 deletions.
42 changes: 25 additions & 17 deletions dist/cos-js-sdk-v5.js
Original file line number Diff line number Diff line change
Expand Up @@ -4474,7 +4474,7 @@ function getObject(params, callback) {
* @param {String} params.GrantRead 赋予被授权者读的权限,格式 x-cos-grant-read: uin=" ",uin=" ",非必须
* @param {String} params.GrantWrite 赋予被授权者写的权限,格式 x-cos-grant-write: uin=" ",uin=" ",非必须
* @param {String} params.GrantFullControl 赋予被授权者读写权限,格式 x-cos-grant-full-control: uin=" ",uin=" ",非必须
* @param {String} params.ServiceSideEncryption 支持按照指定的加密算法进行服务端数据加密,格式 x-cos-server-side-encryption: "AES256",非必须
* @param {String} params.ServerSideEncryption 支持按照指定的加密算法进行服务端数据加密,格式 x-cos-server-side-encryption: "AES256",非必须
* @param {Function} params.onProgress 上传进度回调函数
* @param {Function} callback 回调函数,必须
* @return {Object} err 请求失败的错误,如果请求成功,则为空。
Expand All @@ -4498,7 +4498,7 @@ function putObject(params, callback) {
headers['x-cos-grant-write'] = params['GrantWrite'];
headers['x-cos-grant-full-control'] = params['GrantFullControl'];
headers['x-cos-storage-class'] = params['StorageClass'];
headers['x-cos-server-side-encryption'] = params['ServiceSideEncryption'];
headers['x-cos-server-side-encryption'] = params['ServerSideEncryption'];

for (var key in params) {
if (key.indexOf('x-cos-meta-') > -1) {
Expand Down Expand Up @@ -4759,7 +4759,7 @@ function optionsObject(params, callback) {
* @param {String} Expect 请求的特定的服务器行为
* @param {String} Expires 响应过期的日期和时间
* @param {String} ContentLanguage 指定内容语言
* @param {String} params.ServiceSideEncryption 支持按照指定的加密算法进行服务端数据加密,格式 x-cos-server-side-encryption: "AES256",非必须
* @param {String} params.ServerSideEncryption 支持按照指定的加密算法进行服务端数据加密,格式 x-cos-server-side-encryption: "AES256",非必须
* @param {String} x-cos-meta-* 允许用户自定义的头部信息,将作为 Object 元数据返回。大小限制2K。
*/
function putObjectCopy(params, callback) {
Expand All @@ -4783,7 +4783,7 @@ function putObjectCopy(params, callback) {
headers['Content-Type'] = params['ContentType'];
headers['Expect'] = params['Expect'];
headers['Expires'] = params['Expires'];
headers['x-cos-server-side-encryption'] = params['ServiceSideEncryption'];
headers['x-cos-server-side-encryption'] = params['ServerSideEncryption'];

for (var key in params) {
if (key.indexOf('x-cos-meta-') > -1) {
Expand Down Expand Up @@ -4910,7 +4910,7 @@ function deleteMultipleObject(params, callback) {
* @param {String} params.GrantWrite 赋予被授权者写的权限 ,非必须
* @param {String} params.GrantFullControl 赋予被授权者读写权限 ,非必须
* @param {String} params.StorageClass 设置Object的存储级别,枚举值:Standard,Standard_IA,Nearline,非必须
* @param {String} params.ServiceSideEncryption 支持按照指定的加密算法进行服务端数据加密,格式 x-cos-server-side-encryption: "AES256",非必须
* @param {String} params.ServerSideEncryption 支持按照指定的加密算法进行服务端数据加密,格式 x-cos-server-side-encryption: "AES256",非必须
* @param {Function} callback 回调函数,必须
* @return {Object} err 请求失败的错误,如果请求成功,则为空。
* @return {Object} data 返回的数据
Expand All @@ -4929,7 +4929,7 @@ function multipartInit(params, callback) {
headers['x-cos-grant-write'] = params['GrantWrite'];
headers['x-cos-grant-full-control'] = params['GrantFullControl'];
headers['x-cos-storage-class'] = params['StorageClass'];
headers['x-cos-server-side-encryption'] = params['ServiceSideEncryption'];
headers['x-cos-server-side-encryption'] = params['ServerSideEncryption'];

for (var key in params) {
if (key.indexOf('x-cos-meta-') > -1) {
Expand Down Expand Up @@ -4961,23 +4961,25 @@ function multipartInit(params, callback) {

/**
* 分块上传
* @param {Object} params 参数对象,必须
* @param {String} params.Bucket Bucket名称,必须
* @param {String} params.Region 地域名称,必须
* @param {String} params.Key object名称,必须
* @param {String} params.ContentLength RFC 2616 中定义的 HTTP 请求内容长度(字节),非必须
* @param {String} params.Expect 当使用 Expect: 100-continue 时,在收到服务端确认后,才会发送请求内容,非必须
* @param {String} params.ContentSha1 RFC 3174 中定义的 160-bit 内容 SHA-1 算法校验值,非必须
* @param {Function} callback 回调函数,必须
* @return {Object} err 请求失败的错误,如果请求成功,则为空。
* @return {Object} data 返回的数据
* @return {Object} data.ETag 返回的文件分块 sha1 值
* @param {Object} params 参数对象,必须
* @param {String} params.Bucket Bucket名称,必须
* @param {String} params.Region 地域名称,必须
* @param {String} params.Key object名称,必须
* @param {String} params.ContentLength RFC 2616 中定义的 HTTP 请求内容长度(字节),非必须
* @param {String} params.Expect 当使用 Expect: 100-continue 时,在收到服务端确认后,才会发送请求内容,非必须
* @param {String} params.ContentSha1 RFC 3174 中定义的 160-bit 内容 SHA-1 算法校验值,非必须
* @param {String} params.ServerSideEncryption 支持按照指定的加密算法进行服务端数据加密,格式 x-cos-server-side-encryption: "AES256",非必须
* @param {Function} callback 回调函数,必须
* @return {Object} err 请求失败的错误,如果请求成功,则为空。
* @return {Object} data 返回的数据
* @return {Object} data.ETag 返回的文件分块 sha1 值
*/
function multipartUpload(params, callback) {
var headers = {};

headers['Content-Length'] = params['ContentLength'];
headers['Expect'] = params['Expect'];
headers['x-cos-server-side-encryption'] = params['ServerSideEncryption'];

var PartNumber = params['PartNumber'];
var UploadId = params['UploadId'];
Expand Down Expand Up @@ -9972,6 +9974,7 @@ function sliceUploadFile(params, callback) {
var ChunkSize = params.ChunkSize || params.SliceSize || this.options.ChunkSize;
var AsyncLimit = params.AsyncLimit;
var StorageClass = params.StorageClass || 'Standard';
var ServerSideEncryption = params.ServerSideEncryption;
var FileSize;
var self = this;

Expand Down Expand Up @@ -10017,6 +10020,7 @@ function sliceUploadFile(params, callback) {
FileSize: FileSize,
SliceSize: ChunkSize,
AsyncLimit: AsyncLimit,
ServerSideEncryption: ServerSideEncryption,
UploadData: UploadData,
onProgress: onProgress
}, function (err, data) {
Expand Down Expand Up @@ -10350,6 +10354,7 @@ function uploadSliceList(params, cb) {
var FileSize = params.FileSize;
var SliceSize = params.SliceSize;
var ChunkParallel = params.AsyncLimit || self.options.ChunkParallelLimit || 1;
var ServerSideEncryption = params.ServerSideEncryption;
var Body = params.Body;
var SliceCount = Math.ceil(FileSize / SliceSize);
var FinishSize = 0;
Expand All @@ -10375,6 +10380,7 @@ function uploadSliceList(params, cb) {
SliceSize: SliceSize,
FileSize: FileSize,
PartNumber: PartNumber,
ServerSideEncryption: ServerSideEncryption,
Body: Body,
UploadData: UploadData,
onProgress: function (data) {
Expand Down Expand Up @@ -10419,6 +10425,7 @@ function uploadSliceItem(params, callback) {
var PartNumber = params.PartNumber * 1;
var SliceSize = params.SliceSize;
var UploadData = params.UploadData;
var ServerSideEncryption = params.ServerSideEncryption;
var sliceRetryTimes = 3;
var self = this;

Expand Down Expand Up @@ -10447,6 +10454,7 @@ function uploadSliceItem(params, callback) {
ContentSha1: ContentSha1,
PartNumber: PartNumber,
UploadId: UploadData.UploadId,
ServerSideEncryption: ServerSideEncryption,
Body: Body,
onProgress: params.onProgress
}, function (err, data) {
Expand Down
Loading

0 comments on commit fb99f7c

Please sign in to comment.