我們提供了一套兼容AmazonS3的RESTful API,可以使您更加自由地開發(fā)出靈活的功能
新浪云存儲(chǔ)服務(wù)主要提供以下三類API:
- Service操作
- Bucket操作
- Object操作
與此同時(shí),為提高用戶使用的安全性,新浪云存儲(chǔ)服務(wù)還通過(guò)使用簽名來(lái)驗(yàn)證請(qǐng)求者的身份。
如需了解簽名算法的詳細(xì)信息,請(qǐng)參考《簽名算法》。
如需了解ACL的詳細(xì)信息,請(qǐng)參考《ACL》。
如涉及Bucket和Object的命名規(guī)劃,請(qǐng)參考《約束與限制》。
注意:以下接口中所使用的示例都是在需要使用簽名情況下;如果相關(guān)訪問(wèn)資源已設(shè)置為可匿名(所有用戶)訪問(wèn),則可不帶簽名。
API域名列表:
域名 功能 sinacloud.net 上傳、下載、全部的接口調(diào)用 首選 cdn.sinacloud.net cdn下載加速,只用于下載 下載 up.sinacloud.net cdn上傳加速,只用于上傳 上傳
描述:
獲得當(dāng)前Owner下所有Bucket的列表。
請(qǐng)求格式:
GET /?formatter=json HTTP/1.1
Host: sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
響應(yīng)格式(HTTP Body):
{
"Owner": {
"ID": "SINA0000001234567890"
},
"Buckets": [
{
"ConsumedBytes": 13243241,
"CreationDate": "Fri, 21 Mar 2014 01:13:42 UTC",
"Name": "bucket_name_0"
},
{
"ConsumedBytes": 4323,
"CreationDate": "Fri, 12 Mar 2013 02:25:22 UTC",
"Name": "bucket_name_1"
},
...
]
}
返回值說(shuō)明:
Name | Description |
---|---|
Owner | 所有者 |
Owner.ID | 所有者的UserId |
Buckets | Buckets列表,下一級(jí)為數(shù)組 |
Buckets.Name | Bucket名稱 |
Buckets.ConsumedBytes | 當(dāng)前Bucket已占用空間 |
Buckets.CreationDate | 當(dāng)前Bucket創(chuàng)建時(shí)間 |
請(qǐng)求示例:
curl -v -H "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://sinacloud.net/?formatter=json"
或者
curl -v "http://sinacloud.net/?KID=sina,<access_key>&Expires=1398873316&ssig=<ssig>&formatter=json"
響應(yīng)示例:
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
{
"Owner": {
"ID": "SINA0000001234567890"
},
"Buckets": [
{
"ConsumedBytes": 13243241,
"CreationDate": "Fri, 21 Mar 2014 01:13:42 UTC",
"Name": "bucket_name_0"
},
{
"ConsumedBytes": 4323,
"CreationDate": "Fri, 12 Mar 2013 02:25:22 UTC",
"Name": "bucket_name_1"
},
...
]
}
描述:
獲取bucket下所有object。
請(qǐng)求格式:
GET /?formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
或者
GET /<Your-Bucket-Name>/?formatter=json HTTP/1.1
Host: sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
請(qǐng)求參數(shù):
Parameter | Description | Required |
---|---|---|
delimiter | 折疊顯示字符。通常使用:‘/’ | No |
marker | Key的初始位置,系統(tǒng)將列出比Key大的值,通常用作‘分頁(yè)’的場(chǎng)景 | No |
max-keys | 返回值的最大Key的數(shù)量。默認(rèn)為400 | No |
prefix | 列出以指定字符為開頭的Key | No |
響應(yīng)格式舉例(HTTP Body):
{
Delimiter: "/",
Prefix: "html/",
CommonPrefixes: [
{
Prefix: "html/assets/"
},
{
Prefix: "html/attributions/"
},
{
Prefix: "html/documentation/"
},
...
],
Marker: null,
ContentsQuantity: 5,
CommonPrefixesQuantity: 3,
NextMarker: null,
IsTruncated: false,
Contents: [
{
SHA1: "9fc710aa89efbe42020b0310d16a07449bf06131",
Name: "html/coming-soon.html",
Expiration-Time: null,
Last-Modified: "Fri, 21 Mar 2014 01:50:46 UTC",
Owner: "SINA0000000000000001",
MD5: "934d922cac80449ee361cefeb3276b3e",
Content-Type: "text/html",
Size: 8781
},
{
SHA1: "a9625a128263f05e331f6d78add9bd15911c3565",
Name: "html/ebook.html",
Expiration-Time: null,
Last-Modified: "Fri, 21 Mar 2014 01:50:47 UTC",
Owner: "SINA0000000000000001",
MD5: "cb7ed943ead4aeb513aa8c0b76865a8b",
Content-Type: "text/html",
Size: 18734
},
...
]
}
返回值說(shuō)明:
Name | Description |
---|---|
Contents | Object的Metadata數(shù)組 |
CommonPrefixes | 折疊以后的Prefix,下一級(jí)是Prefix數(shù)組 |
Delimiter | 當(dāng)前使用的折疊字符 |
Prefix | 當(dāng)前使用的前綴 |
Marker | 當(dāng)前使用的Marker |
ContentsQuantity | Contents中元素個(gè)數(shù) |
CommonPrefixesQuantity | CommonPrefixes中元素個(gè)數(shù) |
NextMarker | 下一頁(yè)的Marker |
IsTruncated | 是否還有下一頁(yè) |
SHA1 | 文件內(nèi)容的sha1值 |
Name | Object的Key(文件名) |
Last-Modified | Object的最后修改時(shí)間 |
Owner | Object的擁有者 |
MD5 | 文件內(nèi)容的md5值 |
Content-Type | 文件的mime type |
Size | 文件的大小(字節(jié)) |
應(yīng)用舉例:
假設(shè)某Bucket下有如下文件(為方便說(shuō)明,沒(méi)有顯示為json格式,僅表現(xiàn)其中的一些有用信息,以下同):
join/mailaddresss.txt
join/mycodelist.txt
join/personalfiles/connects.docx
join/personalfiles/myphoto.jpg
join/readme.txt
join/userlist.txt
join/zero.txt
mary/personalfiles/mary.jpg
mary/readme.txt
sai/readme.txt
使用prefix指定以join/為開頭的文件:
GET /?prefix=join/&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
返回:
Contents:
join/mailaddresss.txt
join/mycodelist.txt
join/personalfiles/connects.docx
join/personalfiles/myphoto.jpg
join/readme.txt
join/userlist.txt
join/zero.txt
使用delimiter指定折疊方式為‘/’:
GET /?delimiter=/&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
返回:
Contents:
CommonPrefix:
join
mary
sai
使用prefix指定以join/為開頭的文件,同時(shí)使用delimiter指定折疊方式為‘/’:
GET /?prefix=join/&delimiter=/&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
返回:
Contents:
join/mailaddresss.txt
join/mycodelist.txt
join/readme.txt
join/userlist.txt
join/zero.txt
CommonPrefix:
join/personalfiles/
使用max-keys做最大值列表長(zhǎng)度限制:
GET /?prefix=join/&delimiter=/&max-keys=4&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
返回:
IsTruncated : true
Next-Marker : join/userlist.txt
Contents:
join/mailaddresss.txt
join/mycodelist.txt
join/readme.txt
CommonPrefix:
join/personalfiles/
使用marker繼續(xù)獲得之前的列操作的后續(xù)結(jié)果:
GET /?prefix=join/&delimiter=/&max-keys=4&marker=join/userlist.txt&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
返回:
IsTruncated : false
Contents:
join/userlist.txt
join/zero.txt
描述:
獲取一個(gè)Bucket的meta信息。
請(qǐng)求格式:
GET /?meta&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
響應(yīng):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Connection: keep-alive
Content-Length: 1234
Content-Type: application/json
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
{
DeleteQuantity: 71,
Capacity: 2843723,
ACL: {
GRPS000000ANONYMOUSE: ["read"],
GRPS0000000CANONICAL: [ ],
SINA0000001001HBK3UT: ["read", "write", "read_acp", "write_acp"]
},
ProjectID: 4241,
DownloadQuantity: 93,
DownloadCapacity: 27365564,
CapacityC: 0,
QuantityC: 0,
Project: "Your-Bucket-Name",
UploadCapacity: 9112891,
UploadQuantity: 80,
Last-Modified: "Wed, 16 Apr 2014 13:49:38 UTC",
SizeC: 0,
Owner: "SINA0000001001HBK3UT",
DeleteCapacity: 6269168,
Quantity: 9
}
請(qǐng)求示例:
curl -v -H "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://<Your-Bucket-Name>.sinacloud.net/?meta&formatter=json"
描述:
創(chuàng)建一個(gè)Bucket。
請(qǐng)求格式:
PUT /?formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
x-amz-acl: <Canned-ACL> #請(qǐng)參照《ACL》
或者
PUT /<Your-Bucket-Name>/?formatter=json HTTP/1.1
Host: sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
x-amz-acl: <Canned-ACL> #請(qǐng)參照《ACL》
Request Header(請(qǐng)求頭):
Name | Description | Required |
---|---|---|
x-amz-acl | 創(chuàng)建Bucket的同時(shí),快速設(shè)置一個(gè)Canned-ACL。請(qǐng)參照:《ACL》 | No |
響應(yīng)(無(wú)HTTP Body):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Content-Length: 0
Connection: keep-alive
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
請(qǐng)求示例:
curl -v -X PUT -H "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://<Your-Bucket-Name>.sinacloud.net/?formatter=json"
或者
curl -v -X PUT "http://<Your-Bucket-Name>.sinacloud.net/?KID=sina,<access_key>&Expires=1398873316&ssig=<ssig>&formatter=json"
或者
curl -v -X PUT "http://sinacloud.net/<Your-Bucket-Name>/?KID=sina,<access_key>&Expires=1398873316&ssig=<ssig>&formatter=json"
描述:
刪除指定Bucket。
注意:不能刪除非空Bucket。
請(qǐng)求格式:
DELETE /?formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
或者
DELETE /<Your-Bucket-Name>/?formatter=json HTTP/1.1
Host: sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
響應(yīng)(無(wú)HTTP Body):
HTTP/1.1 204 No Content
Date: Tue, 08 Apr 2014 02:59:47 GMT
Content-Length: 0
Connection: keep-alive
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
請(qǐng)求示例:
curl -v -X DELETE -H "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://<Your-Bucket-Name>.sinacloud.net/?formatter=json"
或者
curl -v -X DELETE "http://<Your-Bucket-Name>.sinacloud.net/?KID=sina,<access_key>&Expires=1398873316&ssig=<ssig>&formatter=json"
或者
curl -v -X DELETE "http://sinacloud.net/<Your-Bucket-Name>/?KID=sina,<access_key>&Expires=1398873316&ssig=<ssig>&formatter=json"
描述:
獲得指定Bucket的ACL信息。更多信息請(qǐng)參照:《ACL》
請(qǐng)求格式:
GET /?acl&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
或者
GET /<Your-Bucket-Name>/?acl&formatter=json HTTP/1.1
Host: sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
響應(yīng):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Content-Length: 123
Connection: keep-alive
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
{
"Owner": "SINA0000000000000001",
"ACL": {
"GRPS000000ANONYMOUSE": [
"read"
],
"SINA0000001001NHT3M7": [
"read",
"write",
"read_acp",
"write_acp"
],
"SINA0000000000000001": [
"read",
"write",
"read_acp",
"write_acp"
],
"SINA0000001001HBK3UT": [
"read",
"write",
"read_acp",
"write_acp"
],
"GRPS0000000CANONICAL": [
"read",
"write",
"read_acp",
"write_acp"
],
...
}
}
響應(yīng)格式說(shuō)明請(qǐng)參照:《ACL》
請(qǐng)求示例:
curl -v -H "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://<Your-Bucket-Name>.sinacloud.net/?acl&formatter=json"
或者
curl -v "http://<Your-Bucket-Name>.sinacloud.net/?acl&KID=sina,<access_key>&Expires=1398873316&ssig=<ssig>&formatter=json"
或者
curl -v "http://sinacloud.net/<Your-Bucket-Name>/?acl&KID=sina,<access_key>&Expires=1398873316&ssig=<ssig>&formatter=json"
描述:
給指定Bucket設(shè)置ACL規(guī)則。更多信息請(qǐng)參照:《ACL》
請(qǐng)求格式:
PUT /?acl&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
#ACL規(guī)則
{
'SINA0000000000000001' : [ "read", "read_acp" , "write", "write_acp" ],
'GRPS000000ANONYMOUSE' : [ "read", "read_acp" , "write", "write_acp" ],
'GRPS0000000CANONICAL' : [ "read", "read_acp" , "write", "write_acp" ],
}
響應(yīng)(無(wú)HTTP Body):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Connection: keep-alive
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
請(qǐng)求格式說(shuō)明請(qǐng)參照:《ACL》
請(qǐng)求示例:
curl -v -T "acl.txt" -H "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://<Your-Bucket-Name>.sinacloud.net/?acl&formatter=json"
描述:
使用HEAD請(qǐng)求方式獲取Object的Metadata。
請(qǐng)求格式:
HEAD /<ObjectName>?formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
響應(yīng)(無(wú)HTTP Body):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Connection: keep-alive
Content-Type: <object-mime-type>
Content-Length: <object-file-bytes>
ETag: "<文件的MD5值>"
Last-Modified: <最后修改時(shí)間>
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
x-amz-meta-foo1: <value1> #自定義meta:foo1
x-amz-meta-foo2: <value2> #自定義meta:foo2
標(biāo)準(zhǔn)Request Headers(請(qǐng)求頭):
Name | Description | Required |
---|---|---|
Range |
Downloads the specified range bytes of an object. For more information about the HTTP Range header, go to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35. ? Type: String ? Default: None ? Constraints: None |
No |
If-Modified-Since |
Return the object only if it has been modified since the specified time, otherwise return a 304 (not modified). ? Type: String ? Default: None ? Constraints: None |
No |
If-Unmodified-Since |
Return the object only if it has not been modified since the specified time, otherwise return a 412 (precondition failed). ? Type: String ? Default: None ? Constraints: None |
No |
If-Match |
Return the object only if its entity tag (ETag) is the same as the one specified; otherwise, return a 412 (precondition failed). ? Type: String ? Default: None ? Constraints: None |
No |
If-None-Match |
Return the object only if its entity tag (ETag) is different from the one specified; otherwise, return a 304 (not modified). ? Type: String ? Default: None ? Constraints: None |
No |
Response Headers(響應(yīng)頭):
Name | Description |
---|---|
Content-Type | Object的mime-type |
Content-Length | Object的Size(bytes) |
ETag | Object的hash值,一般是md5值 |
Last-Modified | Object的最后修改時(shí)間 |
x-amz-meta-* | 用戶可自定義文件屬性信息,讀取時(shí)原值返回。 例如: x-amz-meta-UploadLocation: My Home X-amz-meta-ReviewedBy: test@test.net X-amz-meta-FileChecksum: 0x02661779 X-amz-meta-CheckSumAlgorithm: crc32 |
x-amz-meta-crc32 | Object的CRC32值 |
請(qǐng)求示例:
curl -v -X HEAD -H "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://<Your-Bucket-Name>.sinacloud.net/<Object-Name>?formatter=json"
描述:
獲取一個(gè)Object(下載)。
請(qǐng)求格式:
GET /<ObjectName>?formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
Range: bytes=<byte_range> #支持?jǐn)帱c(diǎn)下載
響應(yīng):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Connection: keep-alive
Content-Type: <object-mime-type>
Content-Length: <object-file-bytes>
ETag: "<文件的MD5值>"
Last-Modified: <最后修改時(shí)間>
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
x-amz-meta-foo1: <value1> #自定義meta:foo1
x-amz-meta-foo2: <value2> #自定義meta:foo2
#文件內(nèi)容
<BODY>
標(biāo)準(zhǔn)Request Headers(請(qǐng)求頭):
Name | Description | Required |
---|---|---|
Range |
Downloads the specified range bytes of an object. For more information about the HTTP Range header, go to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35. ? Type: String ? Default: None ? Constraints: None |
No |
If-Modified-Since |
Return the object only if it has been modified since the specified time, otherwise return a 304 (not modified). ? Type: String ? Default: None ? Constraints: None |
No |
If-Unmodified-Since |
Return the object only if it has not been modified since the specified time, otherwise return a 412 (precondition failed). ? Type: String ? Default: None ? Constraints: None |
No |
If-Match |
Return the object only if its entity tag (ETag) is the same as the one specified; otherwise, return a 412 (precondition failed). ? Type: String ? Default: None ? Constraints: None |
No |
If-None-Match |
Return the object only if its entity tag (ETag) is different from the one specified; otherwise, return a 304 (not modified). ? Type: String ? Default: None ? Constraints: None |
No |
Response Headers(響應(yīng)頭):
Name | Description |
---|---|
Content-Type | Object的mime-type |
Content-Length | Object的Size(bytes) |
ETag | Object的hash值,一般是md5值 |
Last-Modified | Object的最后修改時(shí)間 |
x-amz-meta-* | 用戶可自定義文件屬性信息,讀取時(shí)原值返回。 例如: x-amz-meta-UploadLocation: My Home X-amz-meta-ReviewedBy: test@test.net X-amz-meta-FileChecksum: 0x02661779 X-amz-meta-CheckSumAlgorithm: crc32 |
x-amz-meta-crc32 | Object的CRC32值 |
請(qǐng)求示例:
curl -v -H "Range: bytes=0-1024" -H "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://<Your-Bucket-Name>.sinacloud.net/<Object-Name>?formatter=json"
應(yīng)用舉例:
標(biāo)準(zhǔn)示例:
GET /my_bucket/path/to/my/file.txt?formatter=json HTTP/1.1
Host: sinacloud.net
Date: Sun, 1 Jan 2006 12:00:00 GMT
Authorization: SINA AccessKey:ssig
Range: bytes=100-2048
響應(yīng):
HTTP/1.1 206 Partial Content
x-amz-id-2: id
x-amz-request-id: request_id
Date: date
Last-Modified: Sun, 1 Jan 2006 12:00:00 GMT
ETag: "etag"
Content-Length: length
Content-Type: type
Connection: close
Server: SinaS3
x-amz-meta-foo: foo_value
...
file_content
...
使用各種驗(yàn)證措施的下載方式:
GET /path/to/my/file.txt?KID=sae,youraccount&Expires=1175139620&ssig=your_ssig&ip=time,ipaddress&fn=filename.txt&formatter=json HTTP/1.1
Host: my_bucket.sinacloud.net
Date: date
Range: bytes=byte_range
響應(yīng):
HTTP/1.1 206 Partial Content
x-amz-id-2: id
x-amz-request-id: request_id
Date: date
Last-Modified: Sun, 1 Jan 2006 12:00:00 GMT
ETag: "etag"
Content-Length: length
Content-Type: type
Connection: close
Server: SinaS3
x-amz-meta-foo: foo_value
...
file_content
...
以上示例中QueryString的含義請(qǐng)參照《簽名算法》中的關(guān)于 #認(rèn)證方式# 的說(shuō)明。
描述:
PUT方式上傳一個(gè)文件(同時(shí)可以設(shè)置meta和acl)。
請(qǐng)求格式:
PUT /<ObjectName>?formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Content-Length: <object data length>
Content-Type: <mime-type>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
[object data]
響應(yīng):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Connection: keep-alive
Content-Length: 0
ETag: "<文件的MD5值>"
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
Request Headers(請(qǐng)求頭):
Name | Description | Required |
---|---|---|
x-sina-expire | 文件過(guò)期時(shí)間,到期系統(tǒng)將自動(dòng)清除文件(非即時(shí),清除時(shí)間不定期),格式為:Sat, 20 Nov 2286 17:46:39 GMT | No |
x-sina-info | 固定頭meta信息,支持64位str值,讀取時(shí)原值返回,列文件時(shí)原值返回 | No |
x-sina-info-int | 固定頭meta信息,支持int值,讀取時(shí)原值返回,列文件時(shí)原值返回 | No |
Cache-Control | 文件Cache,標(biāo)準(zhǔn)HTTP協(xié)議,更多內(nèi)容參見(jiàn):http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 | No |
Expires | 文件在客戶端或?yàn)g覽器的緩存過(guò)期時(shí)間,允許客戶端在這個(gè)時(shí)間之前不去服務(wù)端檢查,讀取時(shí)原值返回。格式為:Sun, 29 Jul 2018 20:36:14 UTC | No |
Content-Type | 文件mime type,讀取時(shí)原值返回 | No |
Content-Length | 文件大小,讀取時(shí)原值返回 | Yes |
Content-MD5 | 文件MD5(與傳送內(nèi)容不符時(shí)失?。⒁猓鹤址袷綖閞fc標(biāo)準(zhǔn)使用base64編碼的值 | No |
s-sina-sha1 | 文件SHA-1(與傳送內(nèi)容不符時(shí)失?。?,注意:字符串格式為hex編碼的值 | No |
Content-Disposition | HTTP標(biāo)準(zhǔn)文件屬性信息,讀取時(shí)原值返回。參見(jiàn):http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1 | No |
Content-Encoding | 文件編碼,HTTP標(biāo)準(zhǔn)文件屬性信息,讀取時(shí)原值返回。參見(jiàn):http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11 | No |
x-amz-acl | 文件ACL:創(chuàng)建文件的同時(shí),快速設(shè)置一個(gè)Canned-ACL。請(qǐng)參照:《ACL》 | No |
x-amz-meta-* |
用戶可自定義文件屬性信息,讀取時(shí)原值返回。 例如: x-amz-meta-UploadLocation: My Home X-amz-meta-ReviewedBy: test@test.net X-amz-meta-FileChecksum: 0x02661779 X-amz-meta-CheckSumAlgorithm: crc32 |
No |
請(qǐng)求示例:
curl -v -T "myfile.txt" -H "x-amz-meta-UploadLocation: My Home" -H "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://<Your-Bucket-Name>.sinacloud.net/path/to/myfile.txt?formatter=json"
描述:
POST方式上傳一個(gè)文件(基于瀏覽器表單的上傳方式)。
請(qǐng)求格式:
POST / HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Content-Length: <length>
Content-Type:multipart/form-data; boundary=----WebKitFormBoundary1dIjDASRYXQm6DNA
------WebKitFormBoundary1dIjDASRYXQm6DNA
Content-Disposition: form-data; name="key"
destinationProject/${filename}
------WebKitFormBoundary1dIjDASRYXQm6DNA
Content-Disposition: form-data; name="success_action_redirect"
http://123.abc.com/1.php?f=1111.txt
------WebKitFormBoundary1dIjDASRYXQm6DNA
Content-Disposition: form-data; name="AWSAccessKeyId"
100M414ZO0X30
------WebKitFormBoundary1dIjDASRYXQm6DNA
Content-Disposition: form-data; name="Policy"
eyJleHBpcmF0aW9uIjoiMjAxMi0wNi0wNlQwNjozOTo0MS4wMDBaIiwiY29uZGl0aW9ucyI6W3siYnVja2V0IjoiczN4cC5zM3dhdGNoIn0sWyJzdGFydHMtd2l0aCIsIiRrZXkiLCJhbmdlbFwvIl1dfQ==
------WebKitFormBoundary1dIjDASRYXQm6DNA
Content-Disposition: form-data; name="Signature"
VK6Kw4kRqW2e84ZIX2cV2QqHo58=
------WebKitFormBoundary1dIjDASRYXQm6DNA
Content-Disposition: form-data; name="file"; filename="112233.txt"
Content-Type: text/plain
------WebKitFormBoundary1dIjDASRYXQm6DNA
Content-Disposition: form-data; name="submit"
上傳
------WebKitFormBoundary1dIjDASRYXQm6DNA--
表單元素:
Name | Description | Required |
---|---|---|
AWSAccessKeyId | 就是AccessKey,可以到控制臺(tái)獲取 | Yes |
key | object上傳后的key(路徑),例如:angel/${filename},變量${filename}將被自動(dòng)替換成被上傳文件的文件名;當(dāng)然也可以直接指定被上傳文件存儲(chǔ)在Sinastorage的文件名。如:angel/path/to/myfile.txt | Yes |
acl | 文件的ACL:創(chuàng)建文件的同時(shí),快速設(shè)置一個(gè)Canned-ACL。請(qǐng)參照:《ACL》 | No |
success_action_status | 上傳成功后的響應(yīng)碼,通常設(shè)置為201 | No |
success_action_redirect | 上傳成功后客戶端重定向的URL。 | No |
Policy | 文件的策略,json格式字符串,并使用base64進(jìn)行編碼。后面詳細(xì)介紹 | Yes |
Signature | 使用SecretKey簽名后的字符串。后面詳細(xì)介紹 | Yes |
file | type=file的input表單 | Yes |
x-amz-meta-* | 用戶可自定義文件屬性信息,讀取時(shí)原值返回。 | No |
Cache-Control | 文件的緩存策略(例如:max-age=31536000),讀取時(shí)原值返回。 | No |
Expires | 文件在客戶端或?yàn)g覽器的緩存過(guò)期時(shí)間,允許客戶端在這個(gè)時(shí)間之前不去服務(wù)端檢查,讀取時(shí)原值返回。格式為:Sun, 29 Jul 2018 20:36:14 UTC | No |
Policy的構(gòu)建:
{
"expiration": "2014-04-10T08:55:34.000Z",
"conditions": [
{
"bucket": "my-bucket-name"
},
{
"acl": "private"
},
[
"starts-with", "$key", "my_prefix/"
],
[
"content-length-range", 0, 52428800
]
]
}
以上示例的說(shuō)明:
Signature的構(gòu)建:
base64_encode( hash_hmac( "sha1", $policy, $SECRETKEY, true ) );
最終生成的html表單:
<form method="post" action="http://my-bucket.sinacloud.net/" enctype="multipart/form-data">
<input type="hidden" name="AWSAccessKeyId" value="您的accesskey" />
<input type="hidden" name="key" value="my_prefix/${filename}" />
<input type="hidden" name="acl" value="private" />
<input type="hidden" name="success_action_status" value="201" />
<input type="hidden" name="Policy" value="eyJleHBpcmF0aW9uIjoiMjAxNC0wNC0xMFQwOToxNzozMC4wMDBaIiwiY29uZGl0aW9ucyI6W3siYnVja2V0IjoiY2xvdWQxMjMqwqwsdifsdGFydHMtd2l0aCIsIiRrZXkiLCJteWZpbGVzLyJdLFsic3RhcnRzLXdpdGgiLCIkQ29udGVudC1UeXBlIiwiIl0sWyJzdGFydHMtd2l0aCIsIiRDb250ZW50LURpc3Bvc2l0aW9uIiwiIl0seyJ1aWQiOiIxMjMifSxbImNvbnRlbnQtbGVuZ3RoLXJhbmdlIiwwLDUyNDI4ODAwXV19" />
<input type="hidden" name="Signature" value="HnOSk3kfx5LFtn4CIiFcSglQUXc=" />
<input type="file" name="file" />
<input type="submit" value="上傳" />
</form>
注意事項(xiàng):
您還可以參考PHP-SDK中的例子:https://github.com/SinaCloudStorage/SinaCloudStorage-SDK-PHP/blob/master/examples/example-form.php
描述:
通過(guò)拷貝方式創(chuàng)建Object(不上傳具體的文件內(nèi)容。而是通過(guò)COPY方式對(duì)系統(tǒng)內(nèi)另一文件進(jìn)行復(fù)制)。
請(qǐng)求格式:
PUT /<ObjectName>?formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
x-amz-copy-source: </source-bucket/source-object>
x-amz-metadata-directive: <metadata-directive>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
響應(yīng):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Connection: keep-alive
Content-Length: 0
ETag: "<文件的MD5值>"
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
Request Headers(請(qǐng)求頭):
Name | Description | Required |
---|---|---|
x-amz-copy-source | 被copy的文件地址。格式:/source-bucket/source-object,需要整體進(jìn)行urlencode編碼. | Yes |
x-amz-metadata-directive | 文件Meta以COPY方式填寫還是REPLACE方式填寫,以COPY方式時(shí)會(huì)使用源文件的meta而忽略本次上傳的meta。格式:COPY | REPLACE | No |
x-sina-expire | 文件過(guò)期時(shí)間,到期系統(tǒng)將自動(dòng)清除文件(非即時(shí),清除時(shí)間不定期),格式為:Sat, 20 Nov 2286 17:46:39 GMT | No |
x-sina-info | 固定頭meta信息,支持64位str值,讀取時(shí)原值返回,列文件時(shí)原值返回 | No |
x-sina-info-int | 固定頭meta信息,支持int值,讀取時(shí)原值返回,列文件時(shí)原值返回 | No |
Cache-Control | 文件Cache,標(biāo)準(zhǔn)HTTP協(xié)議,更多內(nèi)容參見(jiàn):http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 | No |
Expires | 文件在客戶端或?yàn)g覽器的緩存過(guò)期時(shí)間,允許客戶端在這個(gè)時(shí)間之前不去服務(wù)端檢查,讀取時(shí)原值返回。格式為:Sun, 29 Jul 2018 20:36:14 UTC | No |
Content-Type | 文件mime type,讀取時(shí)原值返回 | No |
Content-Length | 必須是0 | =0 |
Content-Disposition | HTTP標(biāo)準(zhǔn)文件屬性信息,讀取時(shí)原值返回。參見(jiàn):http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1 | No |
Content-Encoding | 文件編碼,HTTP標(biāo)準(zhǔn)文件屬性信息,讀取時(shí)原值返回。參見(jiàn):http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11 | No |
x-amz-acl | 文件ACL:創(chuàng)建文件的同時(shí),快速設(shè)置一個(gè)Canned-ACL。請(qǐng)參照:《ACL》 | No |
x-amz-meta-* |
用戶可自定義文件屬性信息,讀取時(shí)原值返回。 例如: x-amz-meta-UploadLocation: My Home X-amz-meta-ReviewedBy: test@test.net X-amz-meta-FileChecksum: 0x02661779 X-amz-meta-CheckSumAlgorithm: crc32 |
No |
請(qǐng)求示例:
curl -v -X PUT -H "x-amz-copy-source: /bucket-123/path/to/file123.txt" -H "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://<Your-Bucket-Name>.sinacloud.net/path/to/myfile.txt?formatter=json"
描述:
通過(guò)“秒傳”方式創(chuàng)建Object(不上傳具體的文件內(nèi)容。而是通過(guò)SHA-1值對(duì)系統(tǒng)內(nèi)文件進(jìn)行復(fù)制)。
請(qǐng)求格式:
PUT /<ObjectName>?relax&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Content-Length: 0
Content-Type: <mime-type>
s-sina-sha1:: <文件內(nèi)容的sha1值>
s-sina-length: <要秒傳文件的大小(bytes)>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
響應(yīng):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Connection: keep-alive
Content-Length: 0
ETag: "<文件的MD5值>"
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
Request Headers(請(qǐng)求頭):
Name | Description | Required |
---|---|---|
s-sina-sha1 | 文件SHA-1(系統(tǒng)內(nèi)無(wú)此文件則返回失?。? | Yes |
s-sina-length | 文件大小,讀取時(shí)以Content-Length返回 | Yes |
x-sina-expire | 文件過(guò)期時(shí)間,到期系統(tǒng)將自動(dòng)清除文件(非即時(shí),清除時(shí)間不定期),格式為:Sat, 20 Nov 2286 17:46:39 GMT | No |
x-sina-info | 固定頭meta信息,支持64位str值,讀取時(shí)原值返回,列文件時(shí)原值返回 | No |
x-sina-info-int | 固定頭meta信息,支持int值,讀取時(shí)原值返回,列文件時(shí)原值返回 | No |
Cache-Control | 文件Cache,標(biāo)準(zhǔn)HTTP協(xié)議,更多內(nèi)容參見(jiàn):http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 | No |
Expires | 文件在客戶端或?yàn)g覽器的緩存過(guò)期時(shí)間,允許客戶端在這個(gè)時(shí)間之前不去服務(wù)端檢查,讀取時(shí)原值返回。格式為:Sun, 29 Jul 2018 20:36:14 UTC | No |
Content-Type | 文件mime type,讀取時(shí)原值返回 | No |
Content-Length | 必須是0 | =0 |
Content-Disposition | HTTP標(biāo)準(zhǔn)文件屬性信息,讀取時(shí)原值返回。參見(jiàn):http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1 | No |
Content-Encoding | 文件編碼,HTTP標(biāo)準(zhǔn)文件屬性信息,讀取時(shí)原值返回。參見(jiàn):http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11 | No |
x-amz-acl | 文件ACL:創(chuàng)建文件的同時(shí),快速設(shè)置一個(gè)Canned-ACL。請(qǐng)參照:《ACL》 | No |
x-amz-meta-* |
用戶可自定義文件屬性信息,讀取時(shí)原值返回。 例如: x-amz-meta-UploadLocation: My Home X-amz-meta-ReviewedBy: test@test.net X-amz-meta-FileChecksum: 0x02661779 X-amz-meta-CheckSumAlgorithm: crc32 |
No |
請(qǐng)求示例:
curl -v -X PUT -H "s-sina-sha1: 00fd4b4549a1094aae926ef62e9dbd3cdcc2e456" -H "s-sina-length: 1122" -H "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://<Your-Bucket-Name>.sinacloud.net/path/to/myfile.txt?relax&formatter=json"
描述:
更新一個(gè)已經(jīng)存在的文件的附加meta信息。
注意:這個(gè)接口無(wú)法更新文件的基本信息,如文件的大小和類型等。
請(qǐng)求格式:
PUT /<ObjectName>?meta&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Content-Length: 0
x-amz-meta-foo1: <foo1-value>
x-amz-meta-foo2: <foo2-value>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
響應(yīng):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Connection: keep-alive
Content-Length: 0
ETag: "<文件的MD5值>"
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
Request Headers(請(qǐng)求頭):
Name | Description | Required |
---|---|---|
x-sina-expire | 更新文件過(guò)期時(shí)間,到期系統(tǒng)將自動(dòng)清除文件(非即時(shí),清除時(shí)間不定期),格式為:Sat, 20 Nov 2286 17:46:39 GMT | No |
x-sina-info | 固定頭meta信息,支持64位str值,讀取時(shí)原值返回,列文件時(shí)原值返回 | No |
x-sina-info-int | 固定頭meta信息,支持int值,讀取時(shí)原值返回,列文件時(shí)原值返回 | No |
Cache-Control | 文件Cache,標(biāo)準(zhǔn)HTTP協(xié)議,更多內(nèi)容參見(jiàn):http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 | No |
Expires | 文件在客戶端或?yàn)g覽器的緩存過(guò)期時(shí)間,允許客戶端在這個(gè)時(shí)間之前不去服務(wù)端檢查,讀取時(shí)原值返回。格式為:Sun, 29 Jul 2018 20:36:14 UTC | No |
Content-Type | 文件mime type,讀取時(shí)原值返回 | No |
Content-Disposition | HTTP標(biāo)準(zhǔn)文件屬性信息,讀取時(shí)原值返回。參見(jiàn):http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1 | No |
Content-Encoding | 文件編碼,HTTP標(biāo)準(zhǔn)文件屬性信息,讀取時(shí)原值返回。參見(jiàn):http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11 | No |
x-amz-acl | 文件ACL:更新ACL。請(qǐng)參照:《ACL》 | No |
x-amz-meta-* |
用戶可自定義文件屬性信息,讀取時(shí)原值返回。 例如: x-amz-meta-UploadLocation: My Home X-amz-meta-ReviewedBy: test@test.net X-amz-meta-FileChecksum: 0x02661779 X-amz-meta-CheckSumAlgorithm: crc32 |
No |
請(qǐng)求示例:
curl -v -X PUT -H "x-amz-meta-UploadLocation: My Home" -H "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://<Your-Bucket-Name>.sinacloud.net/path/to/myfile.txt?meta&formatter=json"
描述:
獲取一個(gè)已經(jīng)存在的文件的附加meta信息。
請(qǐng)求格式:
GET /<ObjectName>?meta&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
響應(yīng):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Connection: keep-alive
Content-Length: 1234
Content-Type: application/json
ETag: "<文件的MD5值>"
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
{
"Info": "foo info!",
"File-Name": "myfile.txt",
"Info-Int": 1122,
"Content-MD5": "050fdc0e690bfae7b29392f152bcf305",
"Last-Modified": "Fri, 11 Apr 2014 02:50:31 UTC",
"Content-SHA1": "7c483439a26140b163d82251860ec73d3824d6b0",
"Owner": "SINA0000000000000001",
"Type": "text/plain",
"File-Meta": {
"x-amz-meta-sex": "female",
"x-amz-meta-age": "38",
"x-amz-meta-crc32": "7D45CD11"
},
"Size": 12
}
返回值說(shuō)明:
Name | Description |
---|---|
Info | 創(chuàng)建object時(shí)設(shè)置的 x-sina-info 值。 |
File-Name | object key (文件名)。 |
Info-Int | 創(chuàng)建object時(shí)設(shè)置的 x-sina-info-int 值。 |
Content-MD5 | 文件內(nèi)容的 MD5 值。 |
Content-SHA1 | 文件內(nèi)容的 SHA1 值。 |
Last-Modified | 文件的最后修改時(shí)間。 |
Owner | 文件的所有者。 |
Type | 文件的mime-type。 |
File-Meta | 創(chuàng)建文件時(shí)設(shè)置的x-amz-meta-*值,下一級(jí)為key-value數(shù)組。 |
Size | 文件的大?。╞ytes)。 |
請(qǐng)求示例:
curl -v -H "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://<Your-Bucket-Name>.sinacloud.net/path/to/myfile.txt?meta&formatter=json"
描述:
刪除指定Object。
請(qǐng)求格式:
DELETE /<ObjectName>?formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
響應(yīng)(無(wú)HTTP Body):
HTTP/1.1 204 No Content
Date: Tue, 08 Apr 2014 02:59:47 GMT
Content-Length: 0
Connection: keep-alive
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
請(qǐng)求示例:
curl -v -X DELETE -H "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://<Your-Bucket-Name>.sinacloud.net/path/to/my/file.txt?formatter=json"
描述:
獲得指定Object的ACL信息。更多信息請(qǐng)參照:《ACL》
請(qǐng)求格式:
GET /<ObjectName>?acl&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
響應(yīng):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Content-Length: 123
Connection: keep-alive
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
{
"Owner": "SINA0000000000000001",
"ACL": {
"GRPS000000ANONYMOUSE": [
"read"
],
"SINA0000001001NHT3M7": [
"read",
"write",
"read_acp",
"write_acp"
],
"SINA0000000000000001": [
"read",
"write",
"read_acp",
"write_acp"
],
"SINA0000001001HBK3UT": [
"read",
"write",
"read_acp",
"write_acp"
],
"GRPS0000000CANONICAL": [
"read",
"write",
"read_acp",
"write_acp"
],
...
}
}
響應(yīng)格式說(shuō)明請(qǐng)參照:《ACL》
請(qǐng)求示例:
curl -v -H "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://<Your-Bucket-Name>.sinacloud.net/path/to/my/file.txt?acl&formatter=json"
描述:
給指定Object設(shè)置ACL規(guī)則。更多信息請(qǐng)參照:《ACL》
請(qǐng)求格式:
PUT /<ObjectName>?acl&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
#ACL規(guī)則
{
'SINA0000000000000001' : [ "read", "read_acp" , "write", "write_acp" ],
'GRPS000000ANONYMOUSE' : [ "read", "read_acp" , "write", "write_acp" ],
'GRPS0000000CANONICAL' : [ "read", "read_acp" , "write", "write_acp" ],
}
響應(yīng)(無(wú)HTTP Body):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Connection: keep-alive
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
請(qǐng)求格式說(shuō)明請(qǐng)參照:《ACL》
請(qǐng)求示例:
curl -v -T "acl.txt" -H "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://<Your-Bucket-Name>.sinacloud.net/path/to/my/file.txt?acl&formatter=json"
描述:
大文件分片上傳初始化接口
注意:在初始化上傳接口中要求必須進(jìn)行用戶認(rèn)證,匿名用戶無(wú)法使用該接口。
在初始化上傳時(shí)需要給定文件上傳所需要的meta綁定信息,在后續(xù)的上傳中該信息將被保留,并在最終完成時(shí)寫入云存儲(chǔ)系統(tǒng)。
請(qǐng)求格式:
POST /<ObjectName>?multipart&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Content-Type: <mime-type>
x-amz-meta-foo1: <value1> #自定義meta:foo1
x-amz-meta-foo2: <value2> #自定義meta:foo2
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
響應(yīng):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Connection: keep-alive
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
{
"Bucket": "<Your-Bucket-Name>",
"Key": "<ObjectName>",
"UploadId": "7517c1c49a3b4b86a5f08858290c5cf6"
}
請(qǐng)求示例:
curl -v -X POST "Date: Sat, 20 Nov 2286 17:46:39 GMT" -H "Authorization: SINA <access_key>:<ssig>" "http://<Your-Bucket-Name>.sinacloud.net/path/to/my/file.txt?multipart&formatter=json"
描述:
上傳分片接口
請(qǐng)求格式:
PUT /<ObjectName>?partNumber=<PartNumber>&uploadId=<UploadId>&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Content-Length: <Content-Length>
Content-MD5: <Content-MD5>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
...
file_content
...
響應(yīng):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Connection: keep-alive
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
Etag: <Etag>
請(qǐng)求參數(shù)(QueryString):
Parameter | Description | Required |
---|---|---|
partNumber | 文件分片的序號(hào),從1開始 | Yes |
uploadId | 通過(guò)Initiate Multipart Upload(大文件分片上傳初始化接口)獲得的uploadId值 | Yes |
注意:分片數(shù)不能超過(guò)2048。
描述:
大文件分片上傳拼接完成接口(合并接口)
請(qǐng)求格式:
POST /<ObjectName>?uploadId=<UploadId>&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Content-Type: text/json
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
[
{
"PartNumber": 1,
"ETag": "050fdc0e690bfae7b29392f152bcf301"
},
{
"PartNumber": 2,
"ETag": "050fdc0e690bfae7b29392f152bcf302"
},
{
"PartNumber": 3,
"ETag": "050fdc0e690bfae7b29392f152bcf303"
},
{
"PartNumber": 4,
"ETag": "050fdc0e690bfae7b29392f152bcf304"
},
{
"PartNumber": 5,
"ETag": "050fdc0e690bfae7b29392f152bcf305"
},
...
]
響應(yīng):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Connection: keep-alive
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
請(qǐng)求參數(shù)(QueryString):
Parameter | Description | Required |
---|---|---|
uploadId | 通過(guò)Initiate Multipart Upload(大文件分片上傳初始化接口)獲得的uploadId值 | Yes |
Body內(nèi)容說(shuō)明(json格式):
Name | Description | Required |
---|---|---|
PartNumber | 文件分片的序號(hào) | Yes |
ETag | 通過(guò)Upload Part(上傳分片接口)上傳成功后返回的響應(yīng)頭中的Etag值 | Yes |
描述:
列出已經(jīng)上傳的所有分塊
請(qǐng)求格式:
GET /<ObjectName>?uploadId=<UploadId>&formatter=json HTTP/1.1
Host: <Your-Bucket-Name>.sinacloud.net
Date: <date>
Authorization: <authorization string> #請(qǐng)參照《簽名算法》
響應(yīng):
HTTP/1.1 200 OK
Date: Tue, 08 Apr 2014 02:59:47 GMT
Connection: keep-alive
X-RequestId: 00078d50-1404-0810-5947-782bcb10b128
X-Requester: Your UserId
{
"Bucket": "<Your-Bucket-Name>",
"Key": "<ObjectName>",
"Owner": {
"ID": "<ID>",
"DisplayName": "<DisplayName>"
},
"Parts": [
{
"PartNumber": 1,
"Last-Modified": "Wed, 20 Jun 2012 14:57:10 UTC",
"ETag": "050fdc0e690bfae7b29392f152bcf301",
"Size": 1024
},
{
"PartNumber": 2,
"Last-Modified": "Wed, 20 Jun 2012 14:57:10 UTC",
"ETag": "050fdc0e690bfae7b29392f152bcf302",
"Size": 1024
},
{
"PartNumber": 3,
"Last-Modified": "Wed, 20 Jun 2012 14:57:10 UTC",
"ETag": "050fdc0e690bfae7b29392f152bcf303",
"Size": 1024
},
...
]
}
請(qǐng)求參數(shù)(QueryString):
Parameter | Description | Required |
---|---|---|
uploadId | 通過(guò)Initiate Multipart Upload(大文件分片上傳初始化接口)獲得的uploadId值 | Yes |