上传凭证
Last updated
2023-07-11 15:38:12
{"value":"\u5ba2\u6237\u7aef\u4e0a\u4f20\u524d\u9700\u8981\u5148\u4ece\u670d\u52a1\u7aef\u83b7\u53d6\u4e0a\u4f20\u51ed\u8bc1\uff0c\u5e76\u5728\u4e0a\u4f20\u8d44\u6e90\u65f6\u5c06\u4e0a\u4f20\u51ed\u8bc1\u4f5c\u4e3a\u8bf7\u6c42\u5185\u5bb9\u7684\u4e00\u90e8\u5206\u3002\u4e0d\u5e26\u51ed\u8bc1\u6216\u5e26\u975e\u6cd5\u51ed\u8bc1\u7684\u8bf7\u6c42\u5c06\u8fd4\u56de HTTP \u9519\u8bef\u7801 401\uff0c\u4ee3\u8868\u8ba4\u8bc1\u5931\u8d25\u3002\n\n\u751f\u6210\u4e0a\u4f20\u51ed\u8bc1\u65f6\u9700\u8981\u6307\u5b9a\u4ee5\u4e0b\u8981\u7d20\uff1a\n\n- \u6743\u9650\u3002\u6307\u5b9a\u4e0a\u4f20\u7684\u76ee\u6807\u7a7a\u95f4\u6216\u5141\u8bb8\u8986\u76d6\u7684\u6307\u5b9a\u8d44\u6e90\u3002\n- \u51ed\u8bc1\u6709\u6548\u671f\u3002\u5373\u4e00\u4e2a\u7b26\u5408Unix\u65f6\u95f4\u6233\u89c4\u8303\u7684\u6570\u503c\uff0c\u5355\u4f4d\u4e3a\u79d2\u3002\n *\u6ce8\u610f\uff1a\u56e0\u4e3a Unix \u65f6\u95f4\u6233\u7684\u521b\u5efa\u548c\u9a8c\u8bc1\u5728\u4e0d\u540c\u7684\u670d\u52a1\u7aef\u8fdb\u884c\uff08\u5728\u4e1a\u52a1\u670d\u52a1\u5668\u521b\u5efa\uff0c\u5728\u79c1\u6709\u4e91\u5b58\u50a8\u670d\u52a1\u5668\u9a8c\u8bc1\uff09\uff0c\u56e0\u6b64\u5f00\u53d1\u8005\u7684\u4e1a\u52a1\u670d\u52a1\u5668\u9700\u8981\u5c3d\u53ef\u80fd\u6821\u51c6\u65f6\u95f4\uff0c\u5426\u5219\u53ef\u80fd\u51fa\u73b0\u51ed\u8bc1\u521a\u521b\u5efa\u5c31\u8fc7\u671f\u7b49\u95ee\u9898\u3002*\n- \u53ef\u9009\u62e9\u8bbe\u7f6e\u7684\u6700\u7ec8\u7528\u6237\u6807\u8bc6 ID\u3002\u8fd9\u662f\u4e3a\u4e86\u8ba9\u4e1a\u52a1\u670d\u52a1\u5668\u5728\u6536\u5230\u7ed3\u679c\u56de\u8c03\u65f6\u80fd\u591f\u8bc6\u522b\u4ea7\u751f\u8be5\u8bf7\u6c42\u7684\u6700\u7ec8\u7528\u6237\u4fe1\u606f\u3002\n\n\u6211\u4eec\u4f7f\u7528\u4e0a\u4f20\u7b56\u7565\u6765\u4fdd\u5b58\u548c\u4f20\u9012\u8fd9\u4e9b\u8bbe\u7f6e\u3002\u4e0a\u4f20\u51ed\u8bc1\u662f\u79c1\u6709\u4e91\u5b58\u50a8\u7528\u4e8e\u9a8c\u8bc1\u4e0a\u4f20\u8bf7\u6c42\u5408\u6cd5\u6027\u7684\u673a\u5236\u3002\u7528\u6237\u901a\u8fc7\u4e0a\u4f20\u51ed\u8bc1\u6388\u6743\u5ba2\u6237\u7aef\uff0c\u4f7f\u5176\u5177\u5907\u8bbf\u95ee\u6307\u5b9a\u8d44\u6e90\u7684\u80fd\u529b\u3002\n\n\n\n# \u7b97\u6cd5\n\n1.\u6784\u9020\u4e0a\u4f20\u7b56\u7565\uff1a\n\n\u7528\u6237\u6839\u636e\u4e1a\u52a1\u9700\u6c42\uff0c\u786e\u5b9a\u4e0a\u4f20\u7b56\u7565\u8981\u7d20\uff0c\u6784\u9020\u51fa\u5177\u4f53\u7684\u4e0a\u4f20\u7b56\u7565\u3002\u4f8b\u5982\u7528\u6237\u8981\u5411\u7a7a\u95f4 my-bucket \u4e0a\u4f20\u4e00\u4e2a\u540d\u4e3a sunflower.jpg \u7684\u56fe\u7247\uff0c\u6388\u6743\u6709\u6548\u671f\u622a\u6b62\u5230 2015-12-31 00:00:00\uff08\u8be5\u6709\u6548\u671f\u6307\u4e0a\u4f20\u5b8c\u6210\u540e\u5728\u79c1\u6709\u4e91\u5b58\u50a8\u751f\u6210\u6587\u4ef6\u7684\u65f6\u95f4\uff0c\u800c\u975e\u4e0a\u4f20\u7684\u5f00\u59cb\u65f6\u95f4\uff09\uff0c\u5e76\u4e14\u5e0c\u671b\u5f97\u5230\u56fe\u7247\u7684\u540d\u79f0\u3001\u5927\u5c0f\u3001\u5bbd\u9ad8\u548c\u6821\u9a8c\u503c\u3002\u90a3\u4e48\u76f8\u5e94\u7684\u4e0a\u4f20\u7b56\u7565\u5404\u5b57\u6bb5\u5206\u522b\u4e3a\uff1a\n\n![](https:\/\/tp2lravq.hk03.1112oss.com\/20230711153733no1qtl3u3gs37twd1be35uiu6e3re6e6.png)\n\n2.\u5c06\u4e0a\u4f20\u7b56\u7565\u5e8f\u5217\u5316\u6210\u4e3aJSON]\uff1a\n\n\u7528\u6237\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u8bed\u8a00\u7684 JSON \u5e93\uff0c\u4e5f\u53ef\u4ee5\u624b\u5de5\u62fc\u63a5\u5b57\u7b26\u4e32\u3002\u5e8f\u5217\u5316\u540e\uff0c\u5e94\u5f97\u5230\u5982\u4e0b\u5f62\u5f0f\u7684\u5b57\u7b26\u4e32\uff08\u5b57\u7b26\u4e32\u503c\u4ee5\u5916\u90e8\u5206\u4e0d\u542b\u7a7a\u683c\u6216\u6362\u884c\uff09\uff1a\n\n```\nputPolicy = \n'{\n \"scope\": \"my-bucket:sunflower.jpg\",\n \"deadline\":1451491200,\n \"returnBody\":\n \"{\n \\\"name\\\":$(fname),\n \\\"size\\\":$(fsize),\n \\\"w\\\":$(imageInfo.width),\n \\\"h\\\":$(imageInfo.height),\n \\\"hash\\\":$(etag)\n }\"\n}'\n```\n\n3.\u5bf9 JSON \u7f16\u7801\u7684\u4e0a\u4f20\u7b56\u7565\u8fdb\u884cURL \u5b89\u5168\u7684 Base64 \u7f16\u7801\uff0c\u5f97\u5230\u5f85\u7b7e\u540d\u5b57\u7b26\u4e32\uff1a\n\n```\nencodedPutPolicy = urlsafe_base64_encode(putPolicy)\n\n#\u5b9e\u9645\u503c\u4e3a\uff1a\nencodedPutPolicy = \"eyJzY29wZSI6Im15LWJ1Y2tldDpzdW5mbG93ZXIuanBnIiwiZGVhZGxpbmUiOjE0NTE0OTEyMDAsInJldHVybkJvZHkiOiJ7XCJuYW1lXCI6JChmbmFtZSksXCJzaXplXCI6JChmc2l6ZSksXCJ3XCI6JChpbWFnZUluZm8ud2lkdGgpLFwiaFwiOiQoaW1hZ2VJbmZvLmhlaWdodCksXCJoYXNoXCI6JChldGFnKX0ifQ==\"\n```\n\n4.\u4f7f\u7528\u8bbf\u95ee\u5bc6\u94a5\uff08AK\/SK\uff09\u5bf9\u4e0a\u4e00\u6b65\u751f\u6210\u7684\u5f85\u7b7e\u540d\u5b57\u7b26\u4e32\u8ba1\u7b97HMAC-SHA1\u7b7e\u540d\uff1a\n\n```\nsign = hmac_sha1(encodedPutPolicy, \"<SecretKey>\")\n\n#\u5047\u8bbe SecretKey \u4e3a MY_SECRET_KEY\uff0c\u5b9e\u9645\u7b7e\u540d\u4e3a\uff1a\nsign = \"c10e287f2b1e7f547b20a9ebce2aada26ab20ef2\"\n```\n\n*\u6ce8\u610f\uff1a\u7b7e\u540d\u7ed3\u679c\u662f\u4e8c\u8fdb\u5236\u6570\u636e\uff0c\u6b64\u5904\u8f93\u51fa\u7684\u662f\u6bcf\u4e2a\u5b57\u8282\u7684\u5341\u516d\u8fdb\u5236\u8868\u793a\uff0c\u4ee5\u4fbf\u6838\u5bf9\u68c0\u67e5\u3002*\n\n5.\u5bf9\u7b7e\u540d\u8fdb\u884cURL\u5b89\u5168\u7684Base64\u7f16\u7801\uff1a\n\n```\nencodedSign = urlsafe_base64_encode(sign)\n\n#\u6700\u7ec8\u7b7e\u540d\u503c\u4e3a\uff1a\nencodedSign = \"wQ4ofysef1R7IKnrziqtomqyDvI=\"\n```\n\n6.\u5c06\u8bbf\u95ee\u5bc6\u94a5\uff08AK\/SK\uff09\u3001encodedSign \u548c encodedPutPolicy \u7528\u82f1\u6587\u7b26\u53f7 : \u8fde\u63a5\u8d77\u6765\uff1a\n\n```\nuploadToken = AccessKey + ':' + encodedSign + ':' + encodedPutPolicy\n\n#\u5047\u8bbe\u7528\u6237\u7684 AccessKey \u4e3a MY_ACCESS_KEY \uff0c\u5219\u6700\u540e\u5f97\u5230\u7684\u4e0a\u4f20\u51ed\u8bc1\u5e94\u4e3a\uff1a\nuploadToken = \"MY_ACCESS_KEY:wQ4ofysef1R7IKnrziqtomqyDvI=:eyJzY29wZSI6Im15LWJ1Y2tldDpzdW5mbG93ZXIuanBnIiwiZGVhZGxpbmUiOjE0NTE0OTEyMDAsInJldHVybkJvZHkiOiJ7XCJuYW1lXCI6JChmbmFtZSksXCJzaXplXCI6JChmc2l6ZSksXCJ3XCI6JChpbWFnZUluZm8ud2lkdGgpLFwiaFwiOiQoaW1hZ2VJbmZvLmhlaWdodCksXCJoYXNoXCI6JChldGFnKX0ifQ==\"\n```\n\n*\u6ce8\u610f\uff1a\u4e3a\u786e\u4fdd\u5ba2\u6237\u7aef\u3001\u4e1a\u52a1\u670d\u52a1\u5668\u548c\u79c1\u6709\u4e91\u5b58\u50a8\u670d\u52a1\u5668\u5bf9\u4e8e\u6388\u6743\u622a\u6b62\u65f6\u95f4\u7684\u7406\u89e3\u4fdd\u6301\u4e00\u81f4\uff0c\u9700\u8981\u540c\u6b65\u6821\u51c6\u5404\u81ea\u7684\u65f6\u949f\u3002\u9891\u7e41\u8fd4\u56de 401 \u72b6\u6001\u7801\u65f6\u8bf7\u5148\u68c0\u67e5\u65f6\u949f\u540c\u6b65\u6027\u4e0e\u751f\u6210 deadline \u503c\u7684\u4ee3\u7801\u903b\u8f91\u3002*\n\n\n\n\n\n\n\n# \u793a\u4f8b\n\n\u4e0a\u4f20\u51ed\u8bc1\u4e0d\u9700\u8981\u5355\u72ec\u751f\u6210\uff0c\u79c1\u6709\u4e91\u5b58\u50a8\u652f\u6301\u7684\u670d\u52a1\u7aef\u8bed\u8a00 SDK \u90fd\u5df2\u7ecf\u5c01\u88c5\u597d\uff0c\u5404 SDK \u7684\u5bf9\u5e94\u5165\u53e3\u5982\u4e0b\uff1a\n\n\u00b7 [Java](https:\/\/github.com\/CDNCloudForU\/java-sdk)\n\u00b7 [Python](https:\/\/github.com\/CDNCloudForU\/python-sdk)\n\u00b7 [PHP](https:\/\/github.com\/CDNCloudForU\/php-sdk)\n\u00b7 [Go](https:\/\/github.com\/CDNCloudForU\/api.v7)\n\u00b7 [Android](https:\/\/github.com\/CDNCloudForU\/android-sdk)\n\u00b7 [iOS](https:\/\/github.com\/CDNCloudForU\/objc-sdk)\n\u00b7 [Node.js](https:\/\/github.com\/CDNCloudForU\/nodejs-sdk)\n\u00b7 [JavaScript](https:\/\/github.com\/CDNCloudForU\/js-sdk)\n\u00b7 [C\/C++](https:\/\/github.com\/CDNCloudForU\/c-sdk\/releases)\n\u00b7 [C#](https:\/\/github.com\/CDNCloudForU\/csharp-sdk)\n\n"}