完成MultipartUpload
Last updated
2023-07-14 11:05:15
{"value":"## **\u63cf\u8ff0**\n\n\u5728\u5c06\u6240\u6709\u6570\u636e Part \u90fd\u4e0a\u4f20\u5b8c\u6210\u540e\uff0c\u5fc5\u987b\u8c03\u7528 completeMultipartUpload API \u6765\u5b8c\u6210\u6574\u4e2a\u6587\u4ef6\u7684 Multipart Upload\u3002\u7528\u6237\u9700\u8981\u63d0\u4f9b\u6709\u6548\u6570\u636e\u7684 Part \u5217\u8868\uff08 \u5305\u62ec PartNumber \u548c\u8c03\u7528 uploadPart API \u670d\u52a1\u7aef\u8fd4\u56de\u7684 Etag \uff09\u3002\u670d\u52a1\u7aef\u6536\u5230\u7528\u6237\u63d0\u4ea4\u7684 Part \u5217\u8868\u540e\uff0c\u4f1a\u9010\u4e00\u9a8c\u8bc1\u6bcf\u4e2a\u6570\u636e Part \u7684\u6709\u6548\u6027\u3002\u5f53\u6240\u6709\u7684\u6570\u636e Part \u9a8c\u8bc1\u901a\u8fc7\u540e\uff0c\u4f1a\u628a\u8fd9\u4e9b\u6570\u636e Part \u7ec4\u5408\u6210\u4e00\u4e2a\u5b8c\u6574\u7684 Object\u3002\n\n\n\n\n\n## **\u8bf7\u6c42**\n\n\n\n**\u8bf7\u6c42\u8bed\u6cd5**\n\n```\nPOST \/buckets\/<BucketName>\/objects\/<EncodedObjectName>\/uploads\/<UploadId> HTTP\/1.1\nHost: <UpHost>\nContent-Type: application\/json\nAuthorization: UpToken <UploadToken>\n\n{\n \"parts\": [{ \"etag\": \"<Etag>\", \"partNumber\": <PartNumber> }, ...],\n \"fname\": \"<Fname>\",\n \"mimeType\": \"<MimeType>\",\n \"metadata\": {\"x-qn-meta-<MetaKey>\": \"<MetaValue>\", ...},\n \"customVars\": {\"x:<CustomVarKey>\": \"<CustomVarValue>\", ...}\n}\n```\n\n\u4f7f\u7528\u8bf4\u660e\uff1a\n\n- completeMultipartUpload \u65f6\u4f1a\u786e\u8ba4\u9664\u6700\u540e\u4e00\u5757\u4ee5\u5916\u6240\u6709\u5757\u7684\u5927\u5c0f\u662f\u5426\u90fd\u5927\u4e8e\u7b49\u4e8e 1 MB \uff0c\u5e76\u68c0\u67e5\u7528\u6237\u63d0\u4ea4\u7684 Part \u5217\u8868\u4e2d\u7684\u6bcf\u4e00\u4e2a PartNumber \u548c Etag \u3002\n- \u7528\u6237\u63d0\u4ea4\u7684 Part \u5217\u8868\u4e2d\uff0cPart \u53f7\u7801\u53ef\u4ee5\u4e0d\u8fde\u7eed\uff0c\u4f46\u5fc5\u987b\u662f\u5347\u5e8f\u3002\n- \u670d\u52a1\u7aef\u5904\u7406 completeMultipartUpload \u8bf7\u6c42\u6210\u529f\u540e\uff0c\u8be5 UploadId \u5c31\u4f1a\u53d8\u6210\u65e0\u6548\uff0c\u518d\u6b21\u8bf7\u6c42\u4e0e\u8be5 UploadId \u76f8\u5173\u64cd\u4f5c\u90fd\u4f1a\u5931\u8d25\u3002\n\n\n\n\n\n**\u8bf7\u6c42\u53c2\u6570**\n\n| \u53c2\u6570\u540d\u79f0 | \u5fc5\u586b | \u8bf4\u660e |\n| ----------------- | ---- | ------------------------------------------------------------ |\n| BucketName | \u662f | \u7a7a\u95f4\u540d\u79f0 |\n| EncodedObjectName | \u5426 | \u8d44\u6e90\u540d\uff0cEncodedObjectName \u9700\u8981\u7ecf\u8fc7 Base64 \u7f16\u7801\u3002\u5177\u4f53\u53ef\u4ee5\u53c2\u7167\uff1aURL \u5b89\u5168\u7684 Base64 \u7f16\u7801 |\n| UploadId | \u662f | \u5728\u670d\u52a1\u7aef\u7533\u8bf7\u7684 MultipartUpload \u4efb\u52a1 id |\n\n\n\n\n\n**\u8bf7\u6c42\u5934**\n\n| \u5934\u90e8\u540d\u79f0 | \u5fc5\u586b | \u8bf4\u660e |\n| ------------- | ---- | ------------------------------------------------------------ |\n| Host | \u662f | \u4e0a\u4f20\u57df\u540d\u3002 \u8bbf\u95ee\u57df\u540d\u5217\u8868 |\n| Authorization | \u662f | \u8be5\u53c2\u6570\u5e94\u4e25\u683c\u6309\u7167\u4e0a\u4f20\u51ed\u8bc1]\u683c\u5f0f\u8fdb\u884c\u586b\u5145\uff0c\u5426\u5219\u4f1a\u8fd4\u56de 401 \u9519\u8bef\u7801\u3002\u4e00\u4e2a\u5408\u6cd5\u7684 Authorization \u503c\u5e94\u7c7b\u4f3c\u4e8e Authorization: UpToken QNJi_bYJlmO5LeY08FfoNj9w_r... |\n| Content-Type | \u662f | \u56fa\u5b9a\u4e3a `application\/json` |\n\n\n\n\n\n**\u8bf7\u6c42\u5185\u5bb9**\n\n| \u53c2\u6570\u540d\u79f0 | \u7c7b\u578b | \u5fc5\u586b | \u8bf4\u660e |\n| ---------- | ------ | ---- | ------------------------------------------------------------ |\n| parts | Array | \u662f | \u5df2\u7ecf\u4e0a\u4f20 Part \u5217\u8868 \uff08 \u5305\u62ec PartNumber \uff08 int \uff09\u548c\u8c03\u7528 uploadPart API \u670d\u52a1\u7aef\u8fd4\u56de\u7684 Etag \uff08 string \uff09\uff09 |\n| fname | string | \u5426 | \u4e0a\u4f20\u7684\u539f\u59cb\u6587\u4ef6\u540d\uff0c \u82e5\u672a\u6307\u5b9a\uff0c\u5219\u9b54\u6cd5\u53d8\u91cf\u4e2d\u65e0\u6cd5\u4f7f\u7528 fname\uff0cext\uff0csuffix |\n| mimeType | string | \u5426 | \u82e5\u6307\u5b9a\u4e86\u5219\u8bbe\u7f6e\u4e0a\u4f20\u6587\u4ef6\u7684 mimeType\uff0c \u82e5\u672a\u6307\u5b9a\uff0c\u5219\u6839\u636e\u6587\u4ef6\u5185\u5bb9\u81ea\u52a8\u68c0\u6d4b mimeType |\n| metadata | - | \u5426 | \u7528\u6237\u81ea\u5b9a\u4e49\u6587\u4ef6 metadata \u4fe1\u606f\u7684 key \u548c value\uff0c \u53ef\u4ee5\u8bbe\u7f6e\u591a\u4e2a\uff0cMetaKey \u548c MetaValue \u90fd\u662f string\uff0c\u5176\u4e2d \u53ef\u4ee5\u7531\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u4e0b\u5212\u7ebf\u3001\u51cf\u53f7\u7ec4\u6210\uff0c\u4e14\u957f\u5ea6\u5c0f\u4e8e\u7b49\u4e8e 50\uff0c\u5355\u4e2a\u6587\u4ef6 MetaKey \u548c Metavalue \u603b\u548c\u5927\u5c0f\u4e0d\u80fd\u8d85\u8fc7 1024 \u5b57\u8282 |\n| customVars | - | \u5426 | \u7528\u6237\u81ea\u5b9a\u4e49\u53d8\u91cf\uff0cCustomVarKey \u548c CustomVarValue \u90fd\u662f string |\n\n\n\n\n\n## **\u54cd\u5e94**\n\n\n\n**\u54cd\u5e94\u5934**\n\n\u8be5\u8bf7\u6c42\u64cd\u4f5c\u7684\u5b9e\u73b0\u4f7f\u7528\u4e86\u6240\u6709\u64cd\u4f5c\u7684\u516c\u5171\u54cd\u5e94\u5934\u3002\u6709\u5173\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u67e5\u9605\u516c\u5171\u54cd\u5e94\u5934\u3002\n\n\n\n\n\n**\u54cd\u5e94\u5185\u5bb9**\n\n| \u540d\u79f0 | \u7c7b\u578b | \u8bf4\u660e |\n| ---- | ------ | ------------------------------------ |\n| key | string | \u8d44\u6e90\u540d\u79f0 |\n| hash | string | \u76ee\u6807\u8d44\u6e90\u7684 hash \u503c\uff0c\u53ef\u7528\u4e8e Etag \u5934\u90e8 |\n\n\n\n\n\n**\u54cd\u5e94\u72b6\u6001\u7801**\n\n\u8be5\u64cd\u4f5c\u7684\u5b9e\u73b0\u4e0d\u4f1a\u8fd4\u56de\u7279\u6b8a\u9519\u8bef\u3002\u6709\u5173\u9519\u8bef\u548c\u9519\u8bef\u4ee3\u7801\u5217\u8868\u7684\u4e00\u822c\u4fe1\u606f\uff0c\u8bf7\u67e5\u9605\u9519\u8bef\u54cd\u5e94\u3002\n\n\n\n**\u4e0a\u4f20\u7b56\u7565\u7279\u6b8a\u8bf4\u660e**\n\n\u8be5\u64cd\u4f5c\u7684\u5b9e\u73b0\u4e0d\u652f\u6301\u4e0a\u4f20\u7b56\u7565\u4e2d \" returnUrl \" \uff0c\u8bf7\u67e5\u9605\u4e0a\u4f20\u7b56\u7565\u3002\n\n\n\n\n\n## **\u793a\u4f8b**\n\n\n\n**\u8bf7\u6c42\u793a\u4f8b**\n\n```\nPOST \/buckets\/myBucket\/objects\/bXlPYmplY3Q=\/uploads\/myUploadId HTTP\/1.1\nHost: up.qiniup.com\nContent-Type: application\/json\nAuthorization: UpToken <UploadToken>\n\n{\n \"parts\": [\n {\n \"partNumber\": 1,\n \"etag\": \"FqvtxHpe3j-rEzkImMUWDsmvu27D\"\n }\n ],\n \"mimeType\": \"\"\n}\n```\n\n\n\n\n\n**\u54cd\u5e94\u793a\u4f8b**\n\n```\nHTTP\/1.1 200 OK\nContent-Length: 2\nConnection: keep-alive\nContent-Type: application\/json\nDate: Wed, 18 Dec 2019 17:02:11 GMT\nServer: nginx\nX-Reqid: SFkAAAC8BDebTtsU\n\n{\n \"hash\": \"FqvtxHpe3j-rEzkImMUWDsmvu27D\",\n \"key\": \"myObject\"\n}\n```\n"}