上传图片、视频、音频、文本文件的方法
好热闹
流程
HTML5 通知客户端需要上传文件
Method and URL Structure
| Method |
Resource URL |
| GET |
aichashuo://upload_file |
Request and Parameters
| Name |
Description |
Required |
Default |
| type |
文件类型: audio,image,text,video |
YES |
|
| allowedit |
允许编辑: yes,no |
NO |
yes |
Eample
location.href = "aichashuo://upload_file?type=image&alloedit=no"
获取上传文件用的 token
Method and URL Structure
| Method |
Resource URL |
| POST |
/resources/upload_token |
Request and Parameters
| Name |
Description |
Required |
Default |
| username |
用户名 |
YES |
|
| password |
密码 |
YES |
|
| ext |
后缀名 |
YES |
|
Request
{ "username":"18012345678", "password":"123456", "ext":"ping",}
cURL Example
$ curl -d 'username=18012345678&password=123456&ext=png' http://www.haorenao.cn/resources/upload_token/
JSON Response
| Name |
Description |
| ret |
标示是否成功。ok, 成功; failed, 失败 |
| reason |
失败原因 |
| token |
上传用的 token |
| key |
文件名 |
{ "ret": "ok", "reason": "", "token": "D0OYazeEtx1ZfvvFMBckZqYhSiyGeRtmriKVZUIK:Zq0MgqlWC2o5vv32mRNsA-nlxYQ=:eyJzY29wZSI6Imhhb3JlbmFvOnN0YXRpYy90ZWEvdGhyZWFkaW1hZ2VzLzZiMDEzNjUxNDkwZDIzN2UwNWVmLnBuZyIsImRlYWRsaW5lIjoxNDU5MzE2NDQ2fQ==", "key": "static/tea/threadimages/6b013651490d237e05ef.png",}