[关闭]
@fuyb1986 2016-05-02T14:56:58.000000Z 字数 1284 阅读 719

上传图片、视频、音频、文本文件的方法

好热闹


流程

Created with Raphaël 2.1.2HTML5HTML5ClientClientServerServerQiniuQiniuUpload File: type,[allowedit]Types:audio,image,text,videoSelect FileGet Token: username,password,extext: file stuffix or externsionsGet Token: keyReturn: tokenRuturn: token,keyUpload File: token,keyReturn: keyUpload Done: key

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[1] 允许编辑: yes,no NO yes

Eample

  1. 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

  1. {
  2. "username":"18012345678",
  3. "password":"123456",
  4. "ext":"ping",
  5. }

cURL Example

  1. $ 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 文件名
  1. {
  2. "ret": "ok",
  3. "reason": "",
  4. "token": "D0OYazeEtx1ZfvvFMBckZqYhSiyGeRtmriKVZUIK:Zq0MgqlWC2o5vv32mRNsA-nlxYQ=:eyJzY29wZSI6Imhhb3JlbmFvOnN0YXRpYy90ZWEvdGhyZWFkaW1hZ2VzLzZiMDEzNjUxNDkwZDIzN2UwNWVmLnBuZyIsImRlYWRsaW5lIjoxNDU5MzE2NDQ2fQ==",
  5. "key": "static/tea/threadimages/6b013651490d237e05ef.png",
  6. }

[1] type=image 时有效
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注