1.28.26 put-object

优质
小牛编辑
128浏览
2023-12-01

Put object related api supported by FDS

Version: 1.0.0

/{bucketname}/{objectname}

PUT

Summary:

上传object,如果有同名Object,将会覆盖

Description:

必须拥有Bucket的WRITE权限才能执行该操作

Parameters
NameLocated inDescriptionRequiredSchema
bucketnamepathBucket名字Yesstring
objectnamepath上传的Object名字Yesstring
authorizationheader认证信息,计算方式参考签名认证相关文档Nostring
Dateheader请求时间Yesstring
content-typeheaderObject的content-typeNostring
x-xiaomi-meta-header用户自定义的,以x-xiaomi-meta-为前缀的头部信息Nostring
expiresquery如果上传成功,返回的签名的过期时间戳(UTC),单位毫秒,默认30天Nostring
bodybodyObject内容Yesbinary
Responses
CodeDescriptionSchema
200请求成功PutObjectResult

Models

PutObjectResult

NameTypeDescriptionRequired
bucketNamestring (int32)Bucket名字No
objectNamestringObject名字No
accessKeyIdstring签名用的accessKeyIdNo
signaturestring用于下载这个Object的签名No
expiresstring签名失效时间戳(UTC),单位毫秒,默认有效时间30天No

命令行示例

# 上传tests/test.txt到fds-demo
curl -v -X 'PUT' 'http://cnbj0.fds.api.xiaomi.com/fds-demo/tests/test.txt' \
> -H 'content-type: application/octet-stream' \
> -H 'authorization: Galaxy-V2 541xxx45:LepxxxmQ=' \
> -H 'date: Mon, 27 Feb 2017 09:40:11 GMT' \
> -d 'This is a test'
* Hostname was NOT found in DNS cache
*   Trying 111.206.200.99...
* Connected to cnbj0.fds.api.xiaomi.com (111.206.200.99) port 80 (#0)
> PUT /fds-demo/tests/test.txt HTTP/1.1
> User-Agent: curl/7.35.0
> Host: cnbj0.fds.api.xiaomi.com
> Accept: */*
> content-type: application/octet-stream
> authorization: Galaxy-V2 541xxx45:LepxxxmQ=
> date: Mon, 27 Feb 2017 09:40:11 GMT
> Content-Length: 14
> 
* upload completely sent off: 14 out of 14 bytes
< HTTP/1.1 200 OK
* Server Tengine is not blacklisted
< Server: Tengine
< Date: Mon, 27 Feb 2017 09:41:12 GMT
< Content-Type: application/json
< Content-Length: 152
< Connection: keep-alive
< Access-Control-Allow-Credentials: true
< Access-Control-Max-Age: 1728000
< Access-Control-Allow-Methods: GET, POST, PUT, HEAD, DELETE, OPTIONS
< Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,Content-MD5
< Access-Control-Expose-Headers: content-md5, upload-time, x-xiaomi-meta-content-length
< 
* Connection #0 to host cnbj0.fds.api.xiaomi.com left intact
{"accessKeyId":"54xxx45","bucketName":"fds-demo","expires":1490780472318,"objectName":"tests/test.txt","signature":"6WxxxQ="}
# 上传tests/test.txt到fds-demo,并且
# 指定 content-type
# 指定object为所有人可读
curl -v -X 'PUT' 'http://cnbj0.fds.api.xiaomi.com/fds-demo/tests/test.txt' \
> -H 'content-type: application/json' \
> -H 'authorization: Galaxy-V2 54xxx45:+MxxxN0=' \
> -H 'x-xiaomi-meta-acl: PUBLIC_READ' \
> -H 'date: Mon, 27 Feb 2017 09:58:15 GMT' \
> -d '{}'
* Hostname was NOT found in DNS cache
*   Trying 111.206.200.99...
* Connected to cnbj0.fds.api.xiaomi.com (111.206.200.99) port 80 (#0)
> PUT /fds-demo/tests/test.txt HTTP/1.1
> User-Agent: curl/7.35.0
> Host: cnbj0.fds.api.xiaomi.com
> Accept: */*
> content-type: application/json
> authorization: Galaxy-V2 54xxx45:+MxxxN0=
> x-xiaomi-meta-acl: PUBLIC_READ
> date: Mon, 27 Feb 2017 09:58:15 GMT
> Content-Length: 2
> 
* upload completely sent off: 2 out of 2 bytes
< HTTP/1.1 200 OK
* Server Tengine is not blacklisted
< Server: Tengine
< Date: Mon, 27 Feb 2017 09:59:07 GMT
< Content-Type: application/json
< Content-Length: 152
< Connection: keep-alive
< Access-Control-Allow-Credentials: true
< Access-Control-Max-Age: 1728000
< Access-Control-Allow-Methods: GET, POST, PUT, HEAD, DELETE, OPTIONS
< Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,Content-MD5
< Access-Control-Expose-Headers: content-md5, upload-time, x-xiaomi-meta-content-length
< 
* Connection #0 to host cnbj0.fds.api.xiaomi.com left intact
{"accessKeyId":"54xxx45","bucketName":"fds-demo","expires":1490781547554,"objectName":"tests/test.txt","signature":"MuxxxoQ="}