go-fastdfs/usage.html
2019-10-18 17:53:23 +08:00

864 lines
32 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>语言"SDK" · GitBook</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<link rel="stylesheet" href="gitbook/style.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="usage.html" />
<link rel="prev" href="authentication.html" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="chapter " data-level="1.1" data-path="./">
<a href="./#vision">
愿景
</a>
</li>
<li class="chapter " data-level="1.2" data-path="./">
<a href="./#background">
背景
</a>
<ul class="articles">
<li class="chapter " data-level="1.2.1" data-path="./">
<a href="./#what">
go-fastdfs是什么
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.3" data-path="./">
<a href="./#character">
特性
</a>
<ul class="articles">
<li class="chapter " data-level="1.3.1" data-path="./">
<a href="./#advantage">
go-fastdfs优点
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.4" data-path="install.html">
<a href="install.html">
安装
</a>
<ul class="articles">
<li class="chapter " data-level="1.4.1" data-path="install.html">
<a href="install.html#quick">
极速体验
</a>
</li>
<li class="chapter " data-level="1.4.2" data-path="install.html">
<a href="install.html#docker">
Docker体验
</a>
</li>
<li class="chapter " data-level="1.4.3" data-path="install.html">
<a href="install.html#compiler_install">
编译安装
</a>
</li>
<li class="chapter " data-level="1.4.4" data-path="install.html">
<a href="install.html#small-cluster">
小集群安装
</a>
</li>
<li class="chapter " data-level="1.4.5" data-path="install.html">
<a href="install.html#big-cluster">
海量集群安装(推荐)
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.5" data-path="authentication.html">
<a href="authentication.html">
认证
</a>
<ul class="articles">
<li class="chapter " data-level="1.5.1" data-path="authentication.html">
<a href="authentication.html#fingerprint">
按文件指纹认证
</a>
</li>
<li class="chapter " data-level="1.5.2" data-path="authentication.html">
<a href="authentication.html#google">
按google认证码认证
</a>
</li>
<li class="chapter " data-level="1.5.3" data-path="authentication.html">
<a href="authentication.html#custom">
用户自定义认证
</a>
</li>
</ul>
</li>
<li class="chapter active" data-level="1.6" data-path="usage.html">
<a href="usage.html">
语言"SDK"
</a>
<ul class="articles">
<li class="chapter " data-level="1.6.1" data-path="usage.html">
<a href="usage.html#description">
统一说明(重要)
</a>
</li>
<li class="chapter " data-level="1.6.2" data-path="usage.html">
<a href="usage.html#cmdline">
命令行上传
</a>
</li>
<li class="chapter " data-level="1.6.3" data-path="usage.html">
<a href="usage.html#web">
浏览器上传
</a>
</li>
<li class="chapter " data-level="1.6.4" data-path="usage.html">
<a href="usage.html#python">
Python语言
</a>
</li>
<li class="chapter " data-level="1.6.5" data-path="usage.html">
<a href="usage.html#go">
GO使用
</a>
</li>
<li class="chapter " data-level="1.6.6" data-path="usage.html">
<a href="usage.html#java">
Java语言
</a>
<ul class="articles">
<li class="chapter " data-level="1.6.6.1" data-path="usage.html">
<a href="usage.html#java-stream">
Java流上传
</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="chapter " data-level="1.7" data-path="breakpoint.html">
<a href="breakpoint.html#go">
断点续传"SDK"
</a>
<ul class="articles">
<li class="chapter " data-level="1.7.1" data-path="breakpoint.html">
<a href="breakpoint.html#go">
GO
</a>
</li>
<li class="chapter " data-level="1.7.2" data-path="breakpoint.html">
<a href="breakpoint.html#js">
Javascript
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.8" data-path="api.html">
<a href="api.html">
管理API
</a>
</li>
<li class="chapter " data-level="1.9" data-path="QA.html">
<a href="QA.html">
问题汇总
</a>
<ul class="articles">
<li class="chapter " data-level="1.9.1" data-path="QA.html">
<a href="QA.html">
常见问题
</a>
</li>
<li class="chapter " data-level="1.9.2" data-path="QA.html">
<a href="QA.html">
维护问题
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.10" data-path="upgrade.html">
<a href="upgrade.html">
更新历史
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="." >语言"SDK"</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<h1 id="description">&#x7EDF;&#x4E00;&#x8BF4;&#x660E;&#xFF08;&#x91CD;&#x8981;&#xFF09;</h1>
<pre><code>&#x4ECE;1.3.3&#x5F00;&#x59CB;&#xFF0C;&#x9ED8;&#x8BA4;&#x5F00;&#x542F;&#x7EC4;(support_group_manage=true)&#x529F;&#x80FD;&#xFF08;&#x6709;&#x66F4;&#x597D;&#x7684;&#x6269;&#x5C55;&#x6027;&#xFF09;
&#x8BBF;&#x95EE;&#x7684;url&#x4E2D;&#x90FD;&#x4F1A;&#x5E26;&#x4E0A;group&#x7684;&#x540D;&#x79F0;&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;
http://10.1.5.9:8080/&#x8FD9;&#x91CC;&#x662F;&#x7EC4;&#x540D;/upload
&#x5982;:
http://10.1.5.9:8080/group1/upload
&#x5982;&#x679C;&#xFF08;support_group_manage=false&#xFF09;
url&#x53D8;&#x4E3A;
http://10.1.5.9:8080/upload
</code></pre><h1 id="cmdline">&#x547D;&#x4EE4;&#x4E0A;&#x4F20;</h1>
<p><code>curl -F file=@http-index-fs http://10.1.xx.60:8080/group1/upload</code> </p>
<h1 id="web">WEB&#x4E0A;&#x4F20;&#xFF08;&#x6D4F;&#x89C8;&#x5668;&#x6253;&#x5F00;&#xFF09;</h1>
<p><code>http://yourserver ip:8080/upload.html</code> &#x6CE8;&#x610F;&#xFF1A;&#x4E0D;&#x8981;&#x4F7F;&#x7528;127.0.0.1&#x4E0A;&#x4F20; </p>
<h2 id="python">python&#x7248;&#x672C;: </h2>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> requests
url = <span class="hljs-string">&apos;http://10.1.5.9:8080/group1/upload&apos;</span>
files = {<span class="hljs-string">&apos;file&apos;</span>: open(<span class="hljs-string">&apos;report.xls&apos;</span>, <span class="hljs-string">&apos;rb&apos;</span>)}
options={<span class="hljs-string">&apos;output&apos;</span>:<span class="hljs-string">&apos;json&apos;</span>,<span class="hljs-string">&apos;path&apos;</span>:<span class="hljs-string">&apos;&apos;</span>,<span class="hljs-string">&apos;scene&apos;</span>:<span class="hljs-string">&apos;&apos;</span>} <span class="hljs-comment">#&#x53C2;&#x9605;&#x6D4F;&#x89C8;&#x5668;&#x4E0A;&#x4F20;&#x7684;&#x9009;&#x9879;</span>
r = requests.post(url,data=options, files=files)
print(r.text)
</code></pre>
<h2 id="go">golang&#x7248;&#x672C;</h2>
<pre><code class="lang-go"><span class="hljs-keyword">package</span> main
<span class="hljs-keyword">import</span> (
<span class="hljs-string">&quot;fmt&quot;</span>
<span class="hljs-string">&quot;github.com/astaxie/beego/httplib&quot;</span>
)
<span class="hljs-keyword">func</span> main() {
<span class="hljs-keyword">var</span> obj <span class="hljs-keyword">interface</span>{}
req:=httplib.Post(<span class="hljs-string">&quot;http://10.1.5.9:8080/group1/upload&quot;</span>)
req.PostFile(<span class="hljs-string">&quot;file&quot;</span>,<span class="hljs-string">&quot;filename&quot;</span>)<span class="hljs-comment">//&#x6CE8;&#x610F;&#x4E0D;&#x662F;&#x5168;&#x8DEF;&#x5F84;</span>
req.Param(<span class="hljs-string">&quot;output&quot;</span>,<span class="hljs-string">&quot;json&quot;</span>)
req.Param(<span class="hljs-string">&quot;scene&quot;</span>,<span class="hljs-string">&quot;&quot;</span>)
req.Param(<span class="hljs-string">&quot;path&quot;</span>,<span class="hljs-string">&quot;&quot;</span>)
req.ToJSON(&amp;obj)
fmt.Print(obj)
}
</code></pre>
<h2 id="java">java&#x7248;&#x672C;</h2>
<p>&#x4F9D;&#x8D56;(&#x8FD9;&#x91CC;&#x4F7F;&#x7528;&#x4E86;hutool&#x5DE5;&#x5177;&#x5305;,&#x66F4;&#x7B80;&#x4FBF;)</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>cn.hutool<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>hutool-all<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>4.4.3<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<p>&#x4E0A;&#x4F20;&#x4EE3;&#x7801;</p>
<pre><code class="lang-java"><span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{
<span class="hljs-comment">//&#x6587;&#x4EF6;&#x5730;&#x5740;</span>
File file = <span class="hljs-keyword">new</span> File(<span class="hljs-string">&quot;D:\\git\\2.jpg&quot;</span>);
<span class="hljs-comment">//&#x58F0;&#x660E;&#x53C2;&#x6570;&#x96C6;&#x5408;</span>
HashMap&lt;String, Object&gt; paramMap = <span class="hljs-keyword">new</span> HashMap&lt;&gt;();
<span class="hljs-comment">//&#x6587;&#x4EF6;</span>
paramMap.put(<span class="hljs-string">&quot;file&quot;</span>, file);
<span class="hljs-comment">//&#x8F93;&#x51FA;</span>
paramMap.put(<span class="hljs-string">&quot;output&quot;</span>,<span class="hljs-string">&quot;json&quot;</span>);
<span class="hljs-comment">//&#x81EA;&#x5B9A;&#x4E49;&#x8DEF;&#x5F84;</span>
paramMap.put(<span class="hljs-string">&quot;path&quot;</span>,<span class="hljs-string">&quot;image&quot;</span>);
<span class="hljs-comment">//&#x573A;&#x666F;</span>
paramMap.put(<span class="hljs-string">&quot;scene&quot;</span>,<span class="hljs-string">&quot;image&quot;</span>);
<span class="hljs-comment">//&#x4E0A;&#x4F20;</span>
String result= HttpUtil.post(<span class="hljs-string">&quot;http://xxxxx:xxxx/group1/upload&quot;</span>, paramMap);
<span class="hljs-comment">//&#x8F93;&#x51FA;json&#x7ED3;&#x679C;</span>
System.out.println(result);
}
</code></pre>
<h2 id="java-stream">java&#x7248;&#x672C;&#x6D41;&#x5F0F;&#x4E0A;&#x4F20;</h2>
<p>Hutool-http&#x3001;HttpClient&#x3001;OkHttp3&#x591A;&#x79CD;&#x65B9;&#x5F0F;&#x6D41;&#x5F0F;&#x6587;&#x4EF6;&#x4E0A;&#x4F20;
&#x7531;&#x4E8E;&#x6709;&#x4E0D;&#x5C11;&#x4EBA;&#x95EE;&#x5230;&#x4E0A;&#x9762;&#x7684;&#x95EE;&#x9898;&#xFF0C;&#x73B0;&#x5728;&#x672C;&#x4EBA;&#x603B;&#x7ED3;&#x4E86;&#x4E00;&#x4E2A;&#x5E38;&#x7528;&#x7684;&#x51E0;&#x79CD;http&#x5BA2;&#x6237;&#x7AEF;&#x6587;&#x4EF6;&#x6D41;&#x5F0F;&#x4E0A;&#x4F20;&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x76F8;&#x5F53;&#x4E8E;&#x7ED9;&#x81EA;&#x5DF1;&#x505A;&#x4E0B;&#x8BB0;&#x5F55;&#xFF0C;&#x540C;&#x65F6;&#x4E5F;&#x7ED9;&#x6709;&#x8FD9;&#x65B9;&#x9762;&#x7591;&#x95EE;&#x7684;&#x670B;&#x53CB;&#x4E00;&#x4E2A;&#x501F;&#x9274;&#x3002;&#x5E9F;&#x8BDD;&#x4E0D;&#x591A;&#x8BF4;&#xFF0C;&#x76F4;&#x63A5;&#x4E0A;&#x4EE3;&#x7801;&#x5427;&#x3002;&#x4EE3;&#x7801;&#x662F;&#x57FA;&#x4E8E;springboot&#x7684;maven&#x5DE5;&#x7A0B;&#x3002;</p>
<p>Hutool-http&#x65B9;&#x5F0F;
&#x5148;&#x5728;pom&#x4E2D;&#x6DFB;&#x52A0;hutool&#x7684;&#x4F9D;&#x8D56;</p>
<pre><code class="lang-xml"> <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>cn.hutool<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>hutool-all<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>4.5.1<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<p>&#x63A5;&#x7740;&#x5728;Controller&#x4E2D;&#x4EE3;&#x7801;&#x793A;&#x4F8B;</p>
<pre><code class="lang-java"> <span class="hljs-meta">@RequestMapping</span>(<span class="hljs-string">&quot;/upload&quot;</span>)
<span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">upload</span><span class="hljs-params">(MultipartFile file)</span> </span>{
String result = <span class="hljs-string">&quot;&quot;</span>;
<span class="hljs-keyword">try</span> {
InputStreamResource isr = <span class="hljs-keyword">new</span> InputStreamResource(file.getInputStream(),
file.getOriginalFilename());
Map&lt;String, Object&gt; params = <span class="hljs-keyword">new</span> HashMap&lt;&gt;();
params.put(<span class="hljs-string">&quot;file&quot;</span>, isr);
params.put(<span class="hljs-string">&quot;path&quot;</span>, <span class="hljs-string">&quot;86501729&quot;</span>);
params.put(<span class="hljs-string">&quot;output&quot;</span>, <span class="hljs-string">&quot;json&quot;</span>);
String resp = HttpUtil.post(UPLOAD_PATH, params);
Console.log(<span class="hljs-string">&quot;resp: {}&quot;</span>, resp);
result = resp;
} <span class="hljs-keyword">catch</span> (IOException e) {
e.printStackTrace();
}
<span class="hljs-keyword">return</span> result;
}
</code></pre>
<p>HttpClient&#x65B9;&#x5F0F;
pom&#x4F9D;&#x8D56;</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.apache.httpcomponents<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>httpclient<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.apache.httpcomponents<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>httpmime<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<p>&#x63A5;&#x7740;&#x5728;Controller&#x4E2D;&#x4EE3;&#x7801;&#x793A;&#x4F8B;</p>
<pre><code class="lang-java"> <span class="hljs-meta">@RequestMapping</span>(<span class="hljs-string">&quot;/upload1&quot;</span>)
<span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">upload1</span><span class="hljs-params">(MultipartFile file)</span> </span>{
String result = <span class="hljs-string">&quot;&quot;</span>;
<span class="hljs-keyword">try</span> {
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
CloseableHttpResponse httpResponse = <span class="hljs-keyword">null</span>;
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(<span class="hljs-number">200000</span>)
.setSocketTimeout(<span class="hljs-number">2000000</span>)
.build();
HttpPost httpPost = <span class="hljs-keyword">new</span> HttpPost(UPLOAD_PATH);
httpPost.setConfig(requestConfig);
MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create()
.setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
.setCharset(Charset.forName(<span class="hljs-string">&quot;UTF-8&quot;</span>))
.addTextBody(<span class="hljs-string">&quot;output&quot;</span>, <span class="hljs-string">&quot;json&quot;</span>)
.addBinaryBody(<span class="hljs-string">&quot;file&quot;</span>, file.getInputStream(),
ContentType.DEFAULT_BINARY, file.getOriginalFilename());
httpPost.setEntity(multipartEntityBuilder.build());
httpResponse = httpClient.execute(httpPost);
<span class="hljs-keyword">if</span> (httpResponse.getStatusLine().getStatusCode() == <span class="hljs-number">200</span>) {
String respStr = EntityUtils.toString(httpResponse.getEntity());
System.out.println(respStr);
result = respStr;
}
httpClient.close();
httpResponse.close();
} <span class="hljs-keyword">catch</span> (Exception e) {
e.printStackTrace();
}
<span class="hljs-keyword">return</span> result;
}
</code></pre>
<p>OkHttp3&#x4E0A;&#x4F20;&#x793A;&#x4F8B;
pom&#x6587;&#x4EF6;&#x4F9D;&#x8D56;</p>
<pre><code class="lang-xml"> <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>com.squareup.okhttp3<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>okhttp<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>3.9.1<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<p>&#x63A5;&#x7740;&#x5728;Controller&#x4E2D;&#x4EE3;&#x7801;&#x793A;&#x4F8B;</p>
<pre><code class="lang-java"> <span class="hljs-meta">@RequestMapping</span>(<span class="hljs-string">&quot;/upload2&quot;</span>)
<span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">upload2</span><span class="hljs-params">(MultipartFile file)</span> </span>{
String result = <span class="hljs-string">&quot;&quot;</span>;
<span class="hljs-keyword">try</span> {
OkHttpClient httpClient = <span class="hljs-keyword">new</span> OkHttpClient();
MultipartBody multipartBody = <span class="hljs-keyword">new</span> MultipartBody.Builder().
setType(MultipartBody.FORM)
.addFormDataPart(<span class="hljs-string">&quot;file&quot;</span>, file.getOriginalFilename(),
RequestBody.create(MediaType.parse(<span class="hljs-string">&quot;multipart/form-data;charset=utf-8&quot;</span>),
file.getBytes()))
.addFormDataPart(<span class="hljs-string">&quot;output&quot;</span>, <span class="hljs-string">&quot;json&quot;</span>)
.build();
Request request = <span class="hljs-keyword">new</span> Request.Builder()
.url(UPLOAD_PATH)
.post(multipartBody)
.build();
Response response = httpClient.newCall(request).execute();
<span class="hljs-keyword">if</span> (response.isSuccessful()) {
ResponseBody body = response.body();
<span class="hljs-keyword">if</span> (body != <span class="hljs-keyword">null</span>) {
result = body.string();
System.out.println(result);
}
}
} <span class="hljs-keyword">catch</span> (Exception e) {
e.printStackTrace();
}
<span class="hljs-keyword">return</span> result;
}
</code></pre>
<p>&#x603B;&#x7ED3;
&#x4E0A;&#x9762;&#x7ED9;&#x51FA;&#x4E86;&#x51E0;&#x4E2A;&#x793A;&#x4F8B;&#xFF0C;&#x662F;&#x4E0D;&#x662F;&#x90FD;&#x633A;&#x7B80;&#x5355;&#x7684;&#xFF1F;&#x901A;&#x8FC7;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x5728;Controller&#x4E2D;&#x505A;&#x4E2D;&#x8F6C;&#x4E86;&#xFF0C;&#x8FD8;&#x662F;&#x633A;&#x65B9;&#x4FBF;&#x7684;&#x3002;&#x987A;&#x4FBF;&#x63D0;&#x4E00;&#x4E0B;&#xFF0C;&#x4E0A;&#x9762;&#x51E0;&#x79CD;&#x65B9;&#x5F0F;&#x4E2D;&#xFF0C;&#x6211;&#x4E2A;&#x4EBA;&#x89C9;&#x5F97;Hutool&#x7684;&#x662F;&#x6700;&#x7B80;&#x5355;&#x7684;&#xFF0C;&#x6700;&#x65B9;&#x4FBF;&#x7684;&#xFF0C;&#x5BF9;&#x4E8E;HttpClient&#x800C;&#x8A00;&#xFF0C;&#x6982;&#x5FF5;&#x6BD4;&#x8F83;&#x591A;&#xFF0C;&#x663E;&#x5F97;&#x76F8;&#x5BF9;&#x590D;&#x6742;&#xFF0C;OkHttp&#x4E5F;&#x4E00;&#x6837;&#xFF0C;&#x4E0D;&#x8FC7;&#x6BD4;HttpClient&#x663E;&#x5F97;&#x4F18;&#x96C5;&#x70B9;&#x3002;&#x9488;&#x5BF9;&#x4E00;&#x822C;&#x7684;&#x5E76;&#x53D1;&#x91CF;&#xFF0C;&#x4E2A;&#x4EBA;&#x89C9;&#x5F97;hutool&#x7684;Http&#x5DF2;&#x7ECF;&#x591F;&#x7528;&#x4E86;&#xFF0C;&#x5E95;&#x5C42;&#x662F;&#x57FA;&#x4E8E;jdk&#x7684;HttpUrlConnection&#x5B9E;&#x73B0;&#x7684;&#x3002;&#x5982;&#x679C;&#x5BF9;&#x6027;&#x80FD;&#x6709;&#x7279;&#x6B8A;&#x8981;&#x6C42;&#x7684;&#xFF0C;&#x53EF;&#x4EE5;&#x8003;&#x8651;httpclient&#x6216;&#x8005;OKHttp&#xFF0C;&#x540E;&#x4E24;&#x8005;&#x76F8;&#x5BF9;&#x800C;&#x8A00;&#xFF0C;&#x66F4;&#x63A8;&#x8350;&#x4F7F;&#x7528;OkHttp&#x3002;</p>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="authentication.html#custom" class="navigation navigation-prev " aria-label="Previous page: 用户自定义认证">
<i class="fa fa-angle-left"></i>
</a>
<a href="usage.html#description" class="navigation navigation-next " aria-label="Next page: 统一说明(重要)">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"语言\"SDK\"","level":"1.6","depth":1,"next":{"title":"统一说明(重要)","level":"1.6.1","depth":2,"anchor":"#description","path":"usage.md","ref":"usage.md#description","articles":[]},"previous":{"title":"用户自定义认证","level":"1.5.3","depth":2,"anchor":"#custom","path":"authentication.md","ref":"authentication.md#custom","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"usage.md","mtime":"2019-09-24T02:43:29.637Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-10-18T09:52:12.919Z"},"basePath":".","book":{"language":""}});
});
</script>
</div>
<script src="gitbook/gitbook.js"></script>
<script src="gitbook/theme.js"></script>
<script src="gitbook/gitbook-plugin-livereload/plugin.js"></script>
<script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="gitbook/gitbook-plugin-search/search.js"></script>
<script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>