上传头像
<p><strong>简要描述:</strong> </p>
<ul>
<li>用户上传头像</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>/file/upload</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>POST </li>
</ul>
<p><strong> 请求示例:</strong> </p>
<pre><code>var request = require('request');
var fs = require('fs');
var options = {
'method': 'POST',
'url': 'http://localhost:8080/business/file/upload',
'headers': {
'Authorization': 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX3R5cGUiOiIyIiwidXNlcl9pZCI6IjE1MDMyNzg1MTQ1MjMzOTQwNTAiLCJ1c2VyX2tleSI6ImRiYmMwZjRlLTBjMzgtNGRlNy1iOTFhLTkzYjc3OTlkNTkzMSIsInVzZXJuYW1lIjoiMTM4ODg4ODg4ODgifQ.KjHSmTs0JoGWc4fqn5jrhmSkXvC6k9PfXblY2YDyALntHPBPvMeoBEOnbbrnMpuLMxodt3T3pN2EZhbhBosgtw'
},
formData: {
'file': {
'value': fs.createReadStream('/Users/bin.jiang/Desktop/zyj/在线教育web网页端/images/课程详情_图文)/u1058.png'),
'options': {
'filename': 'u1058.png',
'contentType': null
}
}
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
</code></pre>
<p><strong> 请求参数:</strong> </p>
<ul>
<li>"mimeType": "multipart/form-data"</li>
</ul>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">必选</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">file</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">文件类型</td>
<td>头像文件</td>
</tr>
</tbody>
</table>
<p><strong>返回示例</strong></p>
<pre><code>{
"msg": "操作成功",
"code": 200,
"data": {
"businessId": null,
"fileSize": 14204,
"fileName": "u1058.png",
"name": "u1058.png",
"fileSuffix": "png",
"fileUrl": " https://occ-street-1309741650.cos.ap-guangzhou.myqcloud.com/1505087650122723329.png",
"url": " https://occ-street-1309741650.cos.ap-guangzhou.myqcloud.com/1505087650122723329.png"
}
}</code></pre>
<p><strong>返回参数说明</strong> </p>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">url</td>
<td style="text-align: left;">string</td>
<td>头像文件地址</td>
</tr>
</tbody>
</table>
<p><strong>备注</strong> </p>
<ul>
<li>更多返回错误代码请看首页的错误代码描述</li>
</ul>