分块上传数据
Last updated
2023-07-14 11:00:56
{"value":"## **\u63cf\u8ff0**\n\n\u521d\u59cb\u5316\u4e00\u4e2a Multipart Upload \u4efb\u52a1\u4e4b\u540e\uff0c\u53ef\u4ee5\u6839\u636e\u6307\u5b9a\u7684 EncodedObjectName \u548c UploadId \u6765\u5206 Part \u4e0a\u4f20\u6570\u636e\u3002\n\n\n\n\n\n## **\u8bf7\u6c42**\n\n\n\n**\u8bf7\u6c42\u8bed\u6cd5**\n\n```\nPUT \/buckets\/<BucketName>\/objects\/<EncodedObjectName>\/uploads\/<UploadId>\/<PartNumber> HTTP\/1.1\nHost: <UpHost>\nContent-Type: application\/octet-stream\nContent-MD5: <PartMd5>\nContent-Length: <Size>\nAuthorization: UpToken <UploadToken>\n\n\n<PartContent>\n```\n\n\u4f7f\u7528\u8bf4\u660e\uff1a\n\n- \u6bcf\u4e00\u4e2a\u4e0a\u4f20\u7684 Part \u90fd\u6709\u4e00\u4e2a\u6807\u8bc6\u5b83\u7684\u53f7\u7801 PartNumber\uff0c\u8303\u56f4\u662f 1 - 10000\uff0c\u5355\u4e2a Part\u5927\u5c0f\u8303\u56f4 1 MB - 1 GB\u3002Multipart Upload \u8981\u6c42\u9664\u6700\u540e\u4e00\u4e2a Part \u4ee5\u5916\uff0c\u5176\u4ed6\u7684 Part \u5927\u5c0f\u90fd\u8981\u5927\u4e8e\u7b49\u4e8e 1 MB\u3002\u56e0\u4e0d\u786e\u5b9a\u662f\u5426\u4e3a\u6700\u540e\u4e00\u4e2a Part\uff0cuploadPart API \u5e76\u4e0d\u4f1a\u7acb\u5373\u6821\u9a8c\u4e0a\u4f20 Part \u7684\u5927\u5c0f\uff0c\u5f53 completeMultipartUpload API \u8c03\u7528\u7684\u65f6\u5019\u624d\u4f1a\u6821\u9a8c\u3002\n- \u5982\u679c\u4f60\u7528\u540c\u4e00\u4e2a PartNumber \u4e0a\u4f20\u4e86\u65b0\u7684\u6570\u636e\uff0c\u90a3\u4e48\u670d\u52a1\u7aef\u5df2\u6709\u7684\u8fd9\u4e2a\u53f7\u7801\u7684 Part \u6570\u636e\u5c06\u88ab\u8986\u76d6\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 Multipart Upload \u4efb\u52a1 id |\n| PartNumber | \u662f | \u6bcf\u4e00\u4e2a\u4e0a\u4f20\u7684 Part \u90fd\u6709\u4e00\u4e2a\u6807\u8bc6\u5b83\u7684\u53f7\u7801 |\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\/octet-stream` |\n| Content-MD5 | \u5426 | \u4e0a\u4f20\u5757\u5185\u5bb9\u7684 md5 \u503c\uff0c\u5982\u679c\u6307\u5b9a\u670d\u52a1\u7aef\u4f1a\u8fdb\u884c\u6821\u9a8c\uff0c\u4e0d\u6307\u5b9a\u4e0d\u6821\u9a8c |\n| Content-Length | \u662f | \u4e0a\u4f20\u5757\u5927\u5c0f\uff0c\u5355\u4f4d\u5b57\u8282 |\n\n\n\n\n\n**\u8bf7\u6c42\u5185\u5bb9**\n\n\u8be5\u8bf7\u6c42\u64cd\u4f5c\u7684\u8bf7\u6c42\u4f53\u5757\u7684\u5185\u5bb9\u3002\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| etag | string | \u4e0a\u4f20\u5757\u5185\u5bb9\u7684 etag \uff0c\u7528\u6765\u6807\u8bc6\u5757\uff0ccompleteMultipartUpload API \u8c03\u7528\u7684\u65f6\u5019\u4f5c\u4e3a\u53c2\u6570\u8fdb\u884c\u6587\u4ef6\u5408\u6210 |\n| md5 | string | \u4e0a\u4f20\u5757\u5185\u5bb9\u7684 md5 |\n\n\n\n\n\n**\u54cd\u5e94\u72b6\u6001\u7801**\n\n| HTTP\u72b6\u6001\u7801 | \u542b\u4e49 |\n| ---------- | ------------------------------------------------------------ |\n| 612 | \u76ee\u6807\u8d44\u6e90\u4e0d\u5b58\u5728\uff0c\u5f53\u8bf7\u6c42\u7684 UploadId \u4e0d\u5b58\u5728\u6216\u8005\u5df2\u7ecf complete \u8fc7\u7684\uff0c\u90fd\u4f1a\u8fd4\u56de { \"error\" : \"no such uploadId\" } |\n| 406 | \u670d\u52a1\u7aef\u6821\u9a8c\u5931\u8d25\uff0c\u670d\u52a1\u7aef\u6536\u5230\u6570\u636e\u4e0e\u7528\u6237\u6307\u5b9a\u6821\u9a8c\u503c\u4e0d\u4e00\u81f4\uff0c\u5f53\u6307\u5b9a Content-MD5 \u4e0e\u670d\u52a1\u7aef\u6536\u5230\u6570\u636e\u4e0d\u4e00\u81f4\uff0c\u8fd4\u56de { \"error\" : \"hash not match\" } |\n| 400 | \u4e0d\u7b26\u5408\u8981\u6c42\u7684 PartNumber\uff0c\u4f1a\u8fd4\u56de { \"error\" : \"partNum should be set from 1 to 10000\" } |\n\n\n\n\n\n## **\u793a\u4f8b**\n\n\n\n**\u8bf7\u6c42\u793a\u4f8b**\n\n```\nPUT \/buckets\/myBucket\/objects\/bXlPYmplY3Q=\/uploads\/myUploadID\/1 HTTP\/1.1\nHost: up.qiniup.com\nUser-Agent: Go-http-client\/1.1\nContent-Length: 200\nAuthorization: UpToken j853F3bLkWl59I5BOkWm6q1Z1mZClpr9Z9CLfDE0:nP7NSSyGo4x3W_nJ8T9X1gJrgpk=\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 \"etag\": \"FqvtxHpe3j-rEzkImMUWDsmvu27D\",\n \"md5\": \"4f4acc5d8c71f5fbf04dace00b5360c8\"\n}\n```\n"}