处理结果另存
Last updated
2023-07-17 10:30:01
{"value":"\u4e91\u5b58\u50a8\u63d0\u4f9b\u540d\u4e3a`saveas` \u7684\u6570\u636e\u5904\u7406\u63a5\u53e3\uff0c\u5c06\u5904\u7406\u7ed3\u679c\u4f5c\u4e3a\u8d44\u6e90\u4fdd\u5b58\u5230\u6307\u5b9a\u7a7a\u95f4\u5185\uff0c\u5e76\u8d4b\u4ee5\u6307\u5b9a Key\u3002\u4fdd\u5b58\u6210\u529f\u540e\uff0c\u4e0b\u4e00\u6b21\u53ef\u76f4\u63a5\u901a\u8fc7\u6307\u5b9a Key \u6765\u8bbf\u95ee\u8be5\u8d44\u6e90\uff0c\u4ee5\u8fbe\u5230\u63d0\u5347\u4e0b\u8f7d\u901f\u5ea6\u7684\u6548\u679c\u3002\n\n### **\u9650\u5236\u8bf4\u660e**\n\n- \u6e90Bucket\u548c\u76ee\u6807Bucket\u5fc5\u987b\u5728\u540c\u4e00\u533a\u57df\uff0c\u5373 `\u5904\u7406\u7ed3\u679c\u4e0d\u80fd\u8de8\u533a\u57df\u53e6\u5b58`\uff0c\u4f8b\u5982\u534e\u4e1cBucket\u5185\u7684\u6587\u4ef6\u7ecf\u5904\u7406\u540e\u7ed3\u679c\u65e0\u6cd5\u53e6\u5b58\u5230\u534e\u5317\u7684Bucket\u3002\n- \u652f\u6301`\u540c\u6b65\u8c03\u7528`\u548c`\u6301\u4e45\u5316(pfop)\u8c03\u7528`\uff0c\u4e24\u8005\u8c03\u7528\u65b9\u5f0f\u6709\u8f7b\u5fae\u7684\u5dee\u5f02\u3002\u5927\u591a\u6570\u4f7f\u7528\u573a\u666f\u4e0b\uff0c\u5efa\u8bae\u4f7f\u7528 \u6301\u4e45\u5316\u5904\u7406\u6765\u5b9e\u73b0\u5904\u7406\u7ed3\u679c\u5b58\u50a8\uff0c\u907f\u514d\u4f7f\u7528\u540c\u6b65\u64cd\u4f5c\u7684 saveas \u63a5\u53e3\uff0c\u63d0\u5347\u8bbf\u95ee\u901f\u5ea6\u3002\n- urlsafe_base64_encode() \u51fd\u6570\u6309\u7167\u6807\u51c6\u7684RFC 4648\u5b9e\u73b0\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u53c2\u8003github.com\/qiniu\u4e0a\u5404 SDK \u7684\u6837\u4f8b\u4ee3\u7801\u3002\n- \u5f53\u6301\u4e45\u5316\u4fdd\u5b58\u7684\u5904\u7406\u8017\u65f6\u8f83\u957f\u7684\u65f6\u5019\uff0csaveas \u8bf7\u6c42\u4f1a\u8fd4\u56de\u8d85\u65f6\uff0c\u4f46\u662f\u53ea\u8981\u4fdd\u8bc1\u53d1\u9001\u7684 saveas \u8bf7\u6c42\u5408\u6cd5\uff0c\u670d\u52a1\u7aef\u8fd8\u662f\u4f1a\u5bf9\u8bf7\u6c42\u505a\u6b63\u786e\u5904\u7406\u3002\n- \u6b64\u5904\u7b7e\u540d\u5185\u5bb9\u4e0d\u5305\u542b Scheme \u90e8\u5206\uff0c\u4e0e DownloadToken \u7b7e\u540d\u4e0d\u4e00\u6837\u3002\n- c# http \u5e93\u53d1\u9001\u8bf7\u6c42\u7684\u65f6\u5019\u4f1a\u628a | \u8f6c\u6210 %7c\uff0c\u7531\u4e8e\u7b7e\u540d\u7b7e\u7684\u662f | \uff0c\u5bfc\u81f4\u62a5 400 \u9519\u8bef\u3002\u53ef\u4ee5\u5728\u53d1\u9001\u8bf7\u6c42\u7684\u65f6\u5019\uff0c\u628a url \u4e2d\u7684 | \u6539\u4e3a %7c\uff0c\u6216\u8005\u7b7e\u540d\u7684\u65f6\u5019\u7b7e %7c\u3002\n\n### **\u6301\u4e45\u5316\u8c03\u7528**\n\n### \u63a5\u53e3\u89c4\u683c\n\n```\nsaveas\/<EncodedEntryURI>\/deleteAfterDays\/<deleteAfterDays>\n```\n\n| \u53c2\u6570\u540d\u79f0 | \u5fc5\u586b | \u7c7b\u578b | \u8bf4\u660e |\n| :-----------------: | :--: | :----: | :----------------------------------------------------------- |\n| `<EncodedEntryURI>` | \u662f | string | \u4ee5EncodedEntryURI\u683c\u5f0f\u7ec4\u7ec7\u7684\u76ee\u6807 Bucket \u4e0e Key |\n| `<deleteAfterDays>` | \u5426 | int | \u6700\u5c0f\u5355\u4f4d\u4e3a\u5929\uff0c\u6570\u503c >= 1\u3002\u8868\u793a\u4ece\u4fdd\u5b58\u6570\u636e\u5f00\u59cb\u7b97\u8d77\u591a\u5c11\u5929\u4e4b\u540e\u81ea\u52a8\u4ece bucket \u5220\u9664\u6587\u4ef6\u3002\u4e0d\u8bbe\u7f6e\u8868\u793a\u8d44\u6e90\u4e0d\u4f1a\u88ab\u81ea\u52a8\u5220\u9664 |\n\n\u76f4\u63a5\u5728\u547d\u4ee4\u540e\u8ddf `|saveas\/SafeBase64(bucket:key)\/deleteAfterDays\/< deleteAfterDays >` \u5373\u53ef\uff0c \u5982\uff1a\n\n```\n\"persistentOps\":\"avthumb\/mp3\/ab\/192k|saveas\/dGVzdDoxLm1wMw==\/deleteAfterDays\/3\"\n```\n\n\u8868\u793a\u5904\u7406\u540e\u7684\u6570\u636e\u540d\u79f0\u4e3a\u6307\u5b9a\u7684 key \u5e76\u4e14\u4e0a\u4f20\u5230\u6307\u5b9a\u7684 bucket\uff0c\u5728 3 \u5929\u4e4b\u540e\u4f1a\u4ece bucket \u81ea\u52a8\u5220\u9664\u3002\n\n### **\u540c\u6b65\u8c03\u7528**\n\n\u540c\u6b65\u8c03\u7528\u9700\u8981\u7b7e\u540d\u3002\n\n### \u63a5\u53e3\u89c4\u683c\n\n```\nsaveas\/<EncodedEntryURI>\/sign\/<Sign>\/deleteAfterDays\/<deleteAfterDays>\n```\n\n| \u53c2\u6570\u540d\u79f0 | \u5fc5\u586b | \u7c7b\u578b | \u8bf4\u660e |\n| :-----------------: | :--: | :----: | :----------------------------------------------------- |\n| `<EncodedEntryURI>` | \u662f | string | \u4ee5EncodedEntryURI\u683c\u5f0f\u7ec4\u7ec7\u7684\u76ee\u6807 Bucket \u4e0e Key |\n| `<Sign>` | \u662f | string | \u8bf7\u6c42\u7b7e\u540d\u90e8\u5206\uff0c\u7b97\u6cd5\u89c1\u4e0b\u65b9\uff0c\u5728 pfop \u64cd\u4f5c\u4e2d\u4e0d\u7528\u6307\u5b9a\u8be5\u53c2\u6570 |\n| `<deleteAfterDays>` | \u5426 | int | \u591a\u5c11\u5929\u4e4b\u540e\u81ea\u52a8\u4ece bucket \u5220\u9664\u6587\u4ef6\uff0c\u4ece\u4fdd\u5b58\u6570\u636e\u5f00\u59cb\u7b97\u8d77 |\n\n### \u7b7e\u540d\u7b97\u6cd5\n\n1.\u5728\u4e0b\u8f7d URL\uff08\u4e0d\u542b Scheme \u90e8\u5206\uff0c\u5373\u53bb\u9664 http : \/\/\uff09\u540e\u9644\u52a0 saveas \u63a5\u53e3\uff08\u4e0d\u542b\u7b7e\u540d\u90e8\u5206\uff09\uff1a\n\n```\nNewURL = URL + \"|saveas\/<EncodedEntryURI>\"\n```\n\n2.\u4f7f\u7528 SecretKey \u5bf9\u65b0\u7684\u4e0b\u8f7d URL \u8fdb\u884cHMAC1-SHA1\u7b7e\u540d\uff1a\n\n```\nSign = hmac_sha1(SecretKey, NewURL)\n```\n\n3.\u5bf9\u7b7e\u540d\u8fdb\u884cURL\u5b89\u5168\u7684Base64\u7f16\u7801\uff1a\n\n```\nEncodedSign = urlsafe_base64_encode(Sign)\n```\n\n4.\u5728\u65b0\u7684\u4e0b\u8f7d URL \u540e\u62fc\u63a5\u7b7e\u540d\u53c2\u6570\uff1a\n\n```\nFinalURL = NewURL + \"\/sign\/<AccessKey>:<EncodedSign>\"\n```\n\n**\u540c\u6b65\u8c03\u7528 saveas \u7b97\u6cd5\u793a\u4f8b\uff0c\u751f\u6210 saveas \u8bf7\u6c42\u7684\u5b8c\u6574 Go \u4ee3\u7801\u5982\u4e0b\uff1a**\n\n```\nfunc makeSaveasUrl(URL, accessKey string, secretKey []byte, saveBucket, saveKey string) string {\n encodedEntryURI := base64.URLEncoding.EncodeToString([]byte(saveBucket+\":\"+saveKey))\n URL += \"|saveas\/\" + encodedEntryURI\n h := hmac.New(sha1.New, secretKey)\n \/\/ \u7b7e\u540d\u5185\u5bb9\u4e0d\u5305\u62ecScheme\uff0c\u4ec5\u542b\u5982\u4e0b\u90e8\u5206\uff1a\n \/\/ <Domain>\/<Path>?<Query>\n u, _ := url.Parse(URL)\n io.WriteString(h, u.Host + u.RequestURI())\n d := h.Sum(nil)\n sign := accessKey + \":\" + base64.URLEncoding.EncodeToString(d)\n return URL + \"\/sign\/\" + sign\n}\n```\n\n### **EncodedEntryURI \u683c\u5f0f**\n\n\u672c\u683c\u5f0f\u7528\u4e8e\u5728 URI\u4e2d\u6307\u5b9a\u76ee\u6807\u8d44\u6e90\u7a7a\u95f4\u4e0e\u76ee\u6807\u8d44\u6e90\u540d\uff0c\u683c\u5f0f\u5982\u4e0b\uff1a\n\n```\nentry = '<Bucket>:<Key>'\nencodedEntryURI = urlsafe_base64_encode(entry)\n```\n\n\u5047\u8bbe **entry** \u4e3a `qiniuphotos:gogopher.jpg` \uff0c\u5219\u5bf9\u5e94\u7684 **encodedEntryURI** \u4e3a `cWluaXVwaG90b3M6Z29nb3BoZXIuanBn=` \u3002\n\n#### URL\u5b89\u5168\u7684Base64\u7f16\u7801\n\nURL\u5b89\u5168\u7684Base64\u7f16\u7801\u9002\u7528\u4e8e\u4ee5URL\u65b9\u5f0f\u4f20\u9012Base64\u7f16\u7801\u7ed3\u679c\u7684\u573a\u666f\u3002\u8be5\u7f16\u7801\u65b9\u5f0f\u7684\u57fa\u672c\u8fc7\u7a0b\u662f\u5148\u5c06\u5185\u5bb9\u4ee5Base64\u683c\u5f0f\u7f16\u7801\u4e3a\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u68c0\u67e5\u8be5\u7ed3\u679c\u5b57\u7b26\u4e32\uff0c\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u52a0\u53f7`+`\u6362\u6210\u4e2d\u5212\u7ebf`-`\uff0c\u5e76\u4e14\u5c06\u659c\u6760`\/`\u6362\u6210\u4e0b\u5212\u7ebf`_`\u3002\n\n### **\u81ea\u5b9a\u4e49\u8d44\u6e90\u540d\u652f\u6301\u53d8\u91cf**\n\n\u81ea\u5b9a\u4e49\u76ee\u6807\u8d44\u6e90\u540d\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u53d8\u91cf\uff0c\u652f\u6301 \u9884\u5b9a\u4e49\u53d8\u91cf\u548c\u81ea\u5b9a\u4e49\u53d8\u91cf\uff0c\u53d8\u91cf\u5f15\u7528\u683c\u5f0f\u4e3a`{{.meta.var}}` \u6216 `\u5b57\u7b26\u4e32\u4e0e{{.meta.var}}\u7684\u7ec4\u5408` \u5f62\u5f0f\u6c42\u503c\u3002\n\n### **\u793a\u4f8b**\n\n1.\u539f\u8d44\u6e90\u662f\u4e00\u4e2a\u540d\u4e3a resource\/Ship.jpg \u7684\u56fe\u7247\uff1a\n\n```\nhttp:\/\/78re52.com1.z0.glb.clouddn.com\/resource\/Ship.jpg\n```\n\n2.\u5c06\u56fe\u7247\u505a\u7f29\u7565\u5904\u7406\uff1a\n\n```\nhttp:\/\/78re52.com1.z0.glb.clouddn.com\/resource\/Ship.jpg?imageView2\/2\/w\/200\/h\/200\n```\n\n3.\u5bf9\u4e0a\u8ff0\u4e91\u5904\u7406\u7ed3\u679c\u8fdb\u884c\u6301\u4e45\u5316\u4fdd\u5b58\uff1a\n\n```\n# \u53e6\u5b58\u64cd\u4f5c\u7684\u76ee\u6807\u7a7a\u95f4\u4e0e\u8d44\u6e90\u540d\nentryURI = \"qiniu-developer:Ship-thumb-200.jpg\"\n#\u7f16\u7801\u7ed3\u679c\nencodedEntryURI = \"cWluaXUtZGV2ZWxvcGVyOlNoaXAtdGh1bWItMjAwLmpwZw==\"\n#\u9700\u8981\u7b7e\u540d\u7684\u90e8\u5206\nsigningStr = \"78re52.com1.z0.glb.clouddn.com\/resource\/Ship.jpg?imageView2\/2\/w\/200\/h\/200|saveas\/cWluaXUtZGV2ZWxvcGVyOlNoaXAtdGh1bWItMjAwLmpwZw==\"\n#\u7b7e\u540d\u7ed3\u679c\nsign = \"bcgojLbLKTsTlhm3XFMYq0cn3lW2G3NAuJYXZDDf:jGo09Pmq5vyG4c-rRb4qF3_dH1g=\"\n```\n\n4.\u6700\u7ec8\u5f97\u5230\u7684\u5b8c\u6574\u4e0b\u8f7d URL\uff1a\n\n```\nhttp:\/\/78re52.com1.z0.glb.clouddn.com\/resource\/Ship.jpg?imageView2\/2\/w\/200\/h\/200|saveas\/cWluaXUtZGV2ZWxvcGVyOlNoaXAtdGh1bWItMjAwLmpwZw==\/sign\/bcgojLbLKTsTlhm3XFMYq0cn3lW2G3NAuJYXZDDf:jGo09Pmq5vyG4c-rRb4qF3_dH1g=\n```\n\n5.\u4fdd\u5b58\u8f6c\u7801\u540e\u8d44\u6e90\u53ef\u901a\u8fc7\u5982\u4e0b URL \u8bbf\u95ee\uff1a\n\n```\nhttp:\/\/78re52.com1.z0.glb.clouddn.com\/Ship-thumb-200.jpg\n```\n\n"}