Skip to content

Commit ebb93ad

Browse files
authored
Add sse header (#46)
* add SSE-COS header * fix test * fix README
1 parent 705cc65 commit ebb93ad

File tree

5 files changed

+414
-120
lines changed

5 files changed

+414
-120
lines changed

README.md

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ $args是包含以下字段的关联数组:
9696
| ContentLength | 设置传输长度 | string ||
9797
| ContentMD5 | 设置上传文件的 MD5 值用于校验 | string ||
9898
| Metadata | 用户自定义的文件元信息 | array ||
99+
| ServerSideEncryption | 服务端加密方法 | string ||
99100
#### 示例
100101

101102
```php
@@ -636,13 +637,26 @@ public Guzzle\Service\Resource\Model copyObject(array $args = array());
636637
#### 参数说明
637638

638639
$args是包含以下字段的关联数组:
639-
640-
| 字段名 | 类型 | 默认值 | 是否必填字段 | 描述 |
641-
| :------: | :------------: | :--: | :--------: | :----------------------------------: |
642-
| Bucket | string ||| bucket名称 |
643-
| CopySource | string ||| 复制来源 |
644-
| Key | string ||| 对象名称 |
645-
640+
| 参数名称 | 描述 |类型 | 是否必填字段 |
641+
| -------------- | -------------- |---------- | ----------- |
642+
| Bucket | Bucket 名称,由数字和小写字母以及中划线 "-" 构成 | string ||
643+
| CopySource | 复制来源 | string ||
644+
| Key | 上传文件的路径名,默认从 Bucket 开始 | string ||
645+
| ACL | 设置文件的 ACL,如 'private,public-read','public-read-write' | string ||
646+
| GrantFullControl |赋予指定账户对文件的读写权限 | string ||
647+
| GrantRead | 赋予指定账户对文件读权限 | string ||
648+
| GrantWrite | 赋予指定账户对文件的写权限 | string ||
649+
| StorageClass | 设置文件的存储类型,STANDARD,STANDARD_IA,NEARLINE,默认值:STANDARD | String ||
650+
| Expires | 设置 Content-Expires | string||
651+
| CacheControl | 缓存策略,设置 Cache-Control | string ||
652+
| ContentType | 内容类型,设置 Content-Type |string ||
653+
| ContentDisposition | 文件名称,设置 Content-Disposition | string ||
654+
| ContentEncoding | 编码格式,设置 Content-Encoding | string ||
655+
| ContentLanguage | 语言类型,设置 Content-Language | string ||
656+
| ContentLength | 设置传输长度 | string ||
657+
| ContentMD5 | 设置上传文件的 MD5 值用于校验 | string ||
658+
| Metadata | 用户自定义的文件元信息 | array ||
659+
| ServerSideEncryption | 服务端加密方法 | string ||
646660
#### 示例
647661

648662
```php
@@ -681,16 +695,17 @@ try {
681695
public Guzzle\Service\Resource\Model putBucketLifecycle(array $args = array());
682696
```
683697
#### 参数说明
698+
| 参数名称 | 描述 |类型 | 是否必填字段 |
699+
| -------------- | -------------- |---------- | ----------- |
700+
| Bucket | Bucket 名称,由数字和小写字母以及中划线 "-" 构成 | string ||
701+
| Rules | 设置对应的规则,包括 ID,Filter,Status,Expiration,Transition,NoncurrentVersionExpiration,NoncurrentVersionTransition,AbortIncompleteMultipartUpload | array ||
702+
| ID | 配置规则的 ID | string ||
703+
| Filter | 用于描述规则影响的 Object 集合 | array ||
704+
| Status |设置 Rule 是否启用,可选值为 Enabled 或者 Disabled | string ||
705+
| Expiration | 设置 Object 过期规则,可以指定天数 Days 或者指定日期 Date | array ||
706+
| Transition | 设置 Object 转换存储类型规则,可以指定天数 Days 或者指定日期 Date,StorageClass 可选 Standard_IA, Nearline | array ||
707+
684708

685-
| 字段名 | 类型 | 默认值 | 是否必填字段 | 描述 |
686-
| :------: | :------------: | :--: | :--------: | :----------------------------------: |
687-
| Bucket | string ||| bucket名称 |
688-
| Rules | array ||| 设置对应的规则,包括 ID,Filter,Status,Expiration,Transition,NoncurrentVersionExpiration,NoncurrentVersionTransition,AbortIncompleteMultipartUpload |
689-
| ID | string ||| 配置规则的 ID |
690-
| Filter | array ||| 用于描述规则影响的 Object 集合 |
691-
| Status | array ||| 设置 Rule 是否启用,可选值为 Enabled 或者 Disabled |
692-
| Expiration | array ||| 设置 Object 过期规则,可以指定天数 Days 或者指定日期 Date |
693-
| Transition | array ||| 设置 Object 转换存储类型规则,可以指定天数 Days 或者指定日期 Date,StorageClass 可选 Standard_IA, Nearline |
694709
#### 示例
695710

696711
```php

sample.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
$body = str_repeat('a', 5* 1024 * 1024),
3434
$options = array(
3535
"ACL"=>'private',
36-
'CacheControl' => 'private'));
36+
'CacheControl' => 'private',
37+
'ServerSideEncryption' => 'AES256'));
3738
print_r($result);
3839
} catch (\Exception $e) {
3940
echo "$e\n";
@@ -45,7 +46,8 @@
4546
$result = $cosClient->putObject(array(
4647
'Bucket' => 'testbucket-1252448703',
4748
'Key' => '11//32//43',
48-
'Body' => 'Hello World!'));
49+
'Body' => 'Hello World!',
50+
'ServerSideEncryption' => 'AES256'));
4951
print_r($result);
5052
} catch (\Exception $e) {
5153
echo "$e\n";
@@ -69,8 +71,7 @@
6971
$result = $cosClient->getObject(array(
7072
'Bucket' => 'testbucket-1252448703',
7173
'Key' => '11',
72-
'VersionId' =>'111'
73-
));
74+
'VersionId' =>'111'));
7475
} catch (\Exception $e) {
7576
echo "$e\n";
7677
}
@@ -133,7 +134,8 @@
133134
$result = $cosClient->headObject(array(
134135
'Bucket' => 'testbucket-1252448703',
135136
'Key' => '11',
136-
'VersionId' =>'111'));
137+
'VersionId' =>'111',
138+
'ServerSideEncryption' => 'AES256'));
137139
print_r($result);
138140
} catch (\Exception $e) {
139141
echo "$e\n";
@@ -388,6 +390,7 @@
388390
'CopySource' => 'lewzylu02-1252448703.cos.ap-guangzhou.myqcloud.com/test1G?versionId=MTg0NDY3NDI1NTk0MzUwNDQ1OTg',
389391
// Key is required
390392
'Key' => 'string',
393+
'ServerSideEncryption' => 'AES256'
391394
));
392395
print_r($result);
393396
} catch (\Exception $e) {
@@ -400,7 +403,8 @@
400403
$result = $cosClient->Copy($bucket = 'lewzylu01-1252448703',
401404
$key = 'string',
402405
$copysource = 'lewzylu02-1252448703.cos.ap-guangzhou.myqcloud.com/test1G',
403-
$options = array('VersionId'=>'MTg0NDY3NDI1NTk0MzUwNDQ1OTg'));
406+
$options = array('VersionId'=>'MTg0NDY3NDI1NTk0MzUwNDQ1OTg',
407+
'ServerSideEncryption' => 'AES256'));
404408
print_r($result);
405409
} catch (\Exception $e) {
406410
echo "$e\n";

src/Qcloud/Cos/Copy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Copy {
88
/**
99
* const var: part size from 5MB to 5GB, and max parts of 10000 are allowed for each upload.
1010
*/
11-
const MIN_PART_SIZE = 5242880;
11+
const MIN_PART_SIZE = 52428800 ;
1212
const MAX_PART_SIZE = 5368709120;
1313
const MAX_PARTS = 10000;
1414

0 commit comments

Comments
 (0)