PutObjectAcl
更新时间:2022-01-19
接口描述
此命令用于设置Object的访问权限。目前BOS支持两种方式设置ACL。第一种是使用Canned Acl,在PutObjectAcl的时候,通过头域的"x-bce-acl"或者"x-bce-grant-permission'来设置object访问权限,当前可设置的权限包括private和public-read,两种类型的header不可以同时在一个请求中出现。第二种方式是上传一个ACL文件,文件格式参见ACL文件格式,目前ACL文件只支持accessControlList,grantee,id,permission字段。
目前不支持在同一请求中同时设置canned acl和上传ACL文件。
请求(Request)
-
ACL文件请求语法
PUT /<ObjectKey>?acl HTTP/1.1 Host: <BucketName>.bj.bcebos.com x-bce-date: <Date> Authorization: <AuthorizationString> Content-Type: application/json; charset=utf-8 Content-Length: <ContentLength>
-
Canned ACL文件请求语法(设置x-bce-acl)
PUT /<ObjectKey>?acl HTTP/1.1 Host: <BucketName>.bj.bcebos.com x-bce-date: <Date> Authorization: <AuthorizationString> x-bce-acl: <ObjectAcl> Content-Length: <ContentLength> Content-Type: application/json; charset=utf-8
-
Canned ACL文件请求语法(设置x-bce-grant-permission)
PUT /<ObjectKey>?acl HTTP/1.1 Host: <BucketName>.bj.bcebos.com x-bce-date: <Date> Authorization: <AuthorizationString> x-bce-grant-read: <ObjectGrantRead> Content-Length: <ContentLength> Content-Type: application/json; charset=utf-8
-
请求头域
名称 类型 描述 是否必需 x-bce-acl String Object设置的ACL权限,支持:private、public-read 否 x-bce-grant-read String 授权读的user id,支持多个id,以逗号分隔 否 x-bce-grant-full-control String 授权控制权限的user id,支持多个id,以逗号分隔 否 注意事项
- 只有Bucket的拥有者和被授予FULL_CONTROL权限的用户才能设置Object的ACL权限。
- 在上传Object时,Object权限会默认为空,如果没有设置Object的权限,即当Object权限为空时,默认以Bucket权限为准。
- 当Object权限和Bucket权限不一致时,以Object权限为准。
- 归档存储类型对象在取回未完成,或者刚上传归档类型文件(时长参考取回时长)时,不能设置Object acl。
-
请求参数
无特殊参数
响应(Response)
示例
-
ACL文件请求示例
PUT /ObjectName?acl HTTP/1.1 Host: BucketName.bj.bcebos.com x-bce-date: 2017-05-01T12:23:49Z Authorization: AuthorizationString Content-Type: application/json; charset=utf-8 Content-Length: 315 { "accessControlList":[ { "grantee":[{ "id":"e13b12d0131b4c8bae959df4969387b8" }], "permission":["READ"] } ] }
-
Canned ACL请求示例(设置x-bce-acl)
PUT /ObjectName?acl HTTP/1.1 Host: BucketName.bj.bcebos.com x-bce-date: 2017-05-01T12:23:49Z Authorization: AuthorizationString x-bce-acl: public-read Content-Length: 0 Content-Type: application/json; charset=utf-8
-
Canned ACL请求示例(设置x-bce-grant-permission)
PUT /ObjectName?acl HTTP/1.1 Host: BucketName.bj.bcebos.com x-bce-date: 2017-05-01T12:23:49Z Authorization: AuthorizationString x-bce-grant-read:id="e13b12d0131b4c8bae959df4969387b8",id="8c47a952db4444c5a097b41be3f24c94" Content-Length: 0 Content-Type: application/json; charset=utf-8
-
响应示例
HTTP/1.1 200 OK Date: Wed, 01 Mar 2017 12:25:00 GMT Content-Length: 0 Server: BceBos x-bce-request-id:413e34fd-118d-4049-b992-1b1f3a68b1f5