{"id":427,"date":"2013-08-29T20:58:01","date_gmt":"2013-08-29T12:58:01","guid":{"rendered":"http:\/\/coderbee.net\/?p=427"},"modified":"2013-09-15T15:39:30","modified_gmt":"2013-09-15T07:39:30","slug":"%e5%90%83%e8%87%aa%e5%b7%b1%e7%9a%84%e7%8b%97%e7%b2%ae%ef%bc%8c%e7%94%a8dropbox-go-sdk","status":"publish","type":"post","link":"https:\/\/coderbee.net\/index.php\/go\/20130829\/427","title":{"rendered":"\u5403\u81ea\u5df1\u7684\u72d7\u7cae\uff0c\u7528Dropbox Go SDK"},"content":{"rendered":"<h3>\u83b7\u53d6appKey\u548c\u8bbe\u7f6e\u56de\u8c03\u5730\u5740<\/h3>\n<p>\u5230\u8fd9\u4e2a\u9875\u9762<a href=\"https:\/\/www.dropbox.com\/developers\/apps\">https:\/\/www.dropbox.com\/developers\/apps<\/a> \u521b\u5efa\u4e00\u4e2a\u5e94\u7528\uff0c\u5e94\u7528\u7684\u7c7b\u578b\u9009\u62e9Dropbox API app\uff0c\u5728\u8fd9\u4e2a\u9875\u9762\u8fd8\u53ef\u4ee5\u9009\u62e9\u5e94\u7528\u80fd\u8bbf\u95ee\u7684\u6570\u636e\u8303\u56f4\u3002<\/p>\n<p><strong>\u5f88\u91cd\u8981\u7684\u4e00\u70b9\u5c31\u662f\uff1a\u5e94\u8be5\u53ea\u8d4b\u4e88\u5e94\u7528\u6700\u5c0f\u6743\u9650\uff0c\u4e5f\u5c31\u662f\u53ea\u8bbf\u95ee\u5b83\u81ea\u5df1\u521b\u5efa\u7684\u6587\u4ef6\u3002<\/strong><\/p>\n<p>\u5e94\u7528\u521b\u5efa\u597d\u540e\u5c31\u53ef\u4ee5\u5728\u8be6\u7ec6\u9875\u9762\u67e5\u770b\u5b83\u7684\u7684App key\uff0c\u4e5f\u5c31\u662f\u4e0b\u9762\u8981\u7528\u7684\u3002<\/p>\n<p>\u5728\u5e94\u7528\u7684\u8be6\u7ec6\u9875\u9762\uff0c\u8fd8\u8981\u8bbe\u7f6e\u6388\u6743\u540e\u7684\u56de\u8c03\u5730\u5740\uff0c\u4e5f\u5c31\u662f\u201c OAuth redirect URIs \u201d\u7684\u8f93\u5165\u6846\uff0c\u8fd9\u4e2a\u5730\u5740\u5fc5\u987b\u662f\u5408\u6cd5\u7684URL\uff0c\u54ea\u6015\u662f\u4e0d\u5b58\u5728\u7684\uff0c\u4e5f\u5c31\u662f\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u6210\u201chttps:\/\/127.0.0.1\/oauth2\/authorized\u201d\u3002<\/p>\n<h3>\u83b7\u53d6\u6388\u6743\u7801<\/h3>\n<p>\u5c06\u4e0a\u9762\u5f97\u5230\u7684appKey\u548c\u56de\u8c03\u5730\u5740\u62fc\u63a5\u6210\u4e0b\u9762\u8fd9\u6837\uff1a<br \/>\n<code>https:\/\/www.dropbox.com\/1\/oauth2\/authorize?response_type=token&amp;client_id=abc1234569XYZ&amp;redirect_uri=https:\/\/127.0.0.1\/oauth2\/authorized<\/code><\/p>\n<p>\u91cc\u9762\u7684client_id\u7684\u503c\u586bappKey\uff0credirect_uri\u586b\u56de\u8c03\u5730\u5740\uff0c\u628a\u8fd9\u4e2a\u5730\u5740\u62f7\u8d1d\u5230\u6d4f\u89c8\u5668\u6253\u5f00\uff0c\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u767b\u5f55Dropbox\uff0c\u4f1a\u63d0\u9192\u4f60\u767b\u5f55\uff0c\u767b\u5f55\u540e\u5927\u6982\u662f\u8fd9\u6837\u7684\u754c\u9762\uff1a<br \/>\n<a href=\"\/\/coderbee.net\/wp-content\/uploads\/2013\/08\/vpsBak4coderbee.png\"><img loading=\"lazy\" decoding=\"async\" src=\"\/\/coderbee.net\/wp-content\/uploads\/2013\/08\/vpsBak4coderbee-300x250.png\" alt=\"vpsBak4coderbee\" width=\"300\" height=\"250\" class=\"alignnone size-medium wp-image-426\" srcset=\"https:\/\/coderbee.net\/wp-content\/uploads\/2013\/08\/vpsBak4coderbee-300x250.png 300w, https:\/\/coderbee.net\/wp-content\/uploads\/2013\/08\/vpsBak4coderbee.png 623w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u70b9\u51fb\u201c\u5141\u8bb8\u201d\u6388\u6743\u6210\u529f\u540e\uff0c\u6d4f\u89c8\u5668\u4f1a\u8c03\u6574\uff0c\u5730\u5740\u680f\u91cc\u7684\u5730\u5740\u4f1a\u53d8\uff0c\u62f7\u51fa\u6765\u5927\u6982\u662f\u8fd9\u6837\u7684\uff1a<br \/>\n<code>https:\/\/127.0.0.1\/oauth2\/authorized#access_token=O_xxkdkdkdw2yeidikcppdfdoiffjj&amp;token_type=bearer&amp;uid=158130000<\/code><\/p>\n<p>\u4e0a\u9762\u7684access_token\uff1a <code>O_xxkdkdkdw2yeidikcppdfdoiffjj<\/code>\u5c31\u662f\u4ee3\u7801\u8981\u7528\u7684\u3002<\/p>\n<h3>\u8c03\u7528Go SDK<\/h3>\n<p>\u9996\u5148\u8981\u628asdk clone\u56de\u6765\uff1a git clone https:\/\/github.com\/wen866595\/godropbox.git \uff0c \u8fd9\u6761\u547d\u4ee4\u4f1a\u628asdk\u62f7\u8d1d\u5230\u5f53\u524d\u7684godropbox\u76ee\u5f55\u4e0b\u3002<\/p>\n<pre><code>\npackage main\n\nimport (\n        \".\/dropbox\"\n        \"fmt\"\n        \"os\"\n        \"flag\"\n)\n\nvar (\n        tokens = map[string]string{\n                \"access_token\": \"you oauth2 access token\",\n                \"token_type\":   \"bearer\",\n        }\n)\n\nfunc main() {\n        flag.Parse()\n\n        args := flag.Args()\n        if len(args) < 2 {\n                fmt.Printf(\"Usage: godropbox path\/to\/locale\/file  \/path\/at\/dropbox\\n\")\n                return\n        }\n\n        oauth2 := &#038;dropbox.OAuth2{AccessToken: tokens[\"access_token\"], TokenType: tokens[\"token_type\"]}\n\n        dropboxApi := &#038;dropbox.DropboxApi{Signer: oauth2, Root: \"sandbox\", Locale: \"CN\"}\n\n        localePath, remotePath := flag.Arg(0), flag.Arg(1)\n        _, err := dropboxApi.UploadByChunked(localePath, remotePath, 10485760, 8)   \/\/  10485760\u8868\u793a\u4e00\u6b21\u4e0a\u4f20\u7684\u5757\u5927\u5c0f\u4e3a1M\uff0c\u5bf9\u4e8e\u5927\u6587\u4ef6\uff0c\u8fd9\u4e2a\u503c\u8bbe\u5f97\u5927\u70b9\u53ef\u4ee5\u51cf\u5c11\u4e0a\u4f20\u7684\u6b21\u6570\u3002\n        if err != nil {\n                fmt.Printf(\"error msg: %s\\n\", err)\n                os.Exit(1)\n        } else {\n                os.Exit(0)\n        }\n}\n<\/code><\/pre>\n<p>\u628a\u4e0a\u9762\u7684\u4ee3\u7801\u4fdd\u5b58\u5728main.go\u6587\u4ef6\u91cc\u9762\uff0c\u653e\u5230godropbox\u76ee\u5f55\u4e0b\uff0c\u5230godropbox\u76ee\u5f55\u7528 <code>go build<\/code>\u547d\u4ee4\u6784\u5efa\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5728\u6211\u7684VPS\u4e0a\u4f7f\u7528\uff1a <code>.\/godropbox path\/to\/locale\/file  \/path\/at\/dropbox<\/code>\uff0c\u6548\u679c\u8fd8\u884c\u3002<\/p>\n<p>\u4ee5\u524d\u7528Java SDK\u5199\u8fc7\u4e00\u4e2a\u4e0a\u4f20\u7684\u529f\u80fd\uff0c\u6587\u4ef6\u4e0a\u4f20\u5b8c\u4e86\u8fd8\u8981\u5f88\u4e45\u624d\u9000\u51fa\u3002<\/p>\n<hr\/>\n<p>\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u5fae\u4fe1\u516c\u4f17\u53f7: <strong>coderbee\u7b14\u8bb0<\/strong>\uff0c\u53ef\u4ee5\u66f4\u53ca\u65f6\u56de\u590d\u4f60\u7684\u8ba8\u8bba\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"258\" height=\"258\" src=\"https:\/\/coderbee.net\/wp-content\/uploads\/2019\/01\/coderbee-note.jpg\" class=\"alignnone size-full wp-image-1707\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u83b7\u53d6appKey\u548c\u8bbe\u7f6e\u56de\u8c03\u5730\u5740 \u5230\u8fd9\u4e2a\u9875\u9762https:\/\/www.dropbox &hellip; <a href=\"https:\/\/coderbee.net\/index.php\/go\/20130829\/427\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45],"tags":[82,232],"_links":{"self":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/427"}],"collection":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/comments?post=427"}],"version-history":[{"count":9,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/427\/revisions"}],"predecessor-version":[{"id":475,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/427\/revisions\/475"}],"wp:attachment":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/media?parent=427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/categories?post=427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/tags?post=427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}