API:上传文件
PUT https://file.bimface.com/upload
上传文件支持两种方式,push、pull, 两种方式是互斥的。push:在request body中传入文件流; pull:在url参数中传入文件的下载地址。
请求(Request)
Header
| key |
value |
示例 |
| Authorization |
bearer {accessToken} |
bearer xxxx-xxxx-xxxx-xxxx |
| Content-Type |
application/json |
… |
| Content-Length |
文件长度(字节数),注:在push方式下必填 |
1024 |
Url Parameter
| 字段 |
类型 |
必填 |
描述 |
示例 |
| name |
String |
Y |
文件的全名,使用URL编码(UTF-8),最多256个字符 |
abc.rvt |
| sourceId |
String |
N |
调用方的文件源ID,不能重复 |
… |
| url |
String |
N |
文件的下载地址,使用URL编码(UTF-8),最多512个字符,注:在pull方式下必填,必须以http(s)://开头 |
http://downloadUrl |
Request Body
文件流
curl -X PUT
-H "Authorization: bearer <your accessToken>"
-H "Content-Type: application/json"
-T "<your local file>"
"https://file.bimface.com/upload?name=<your file name>"
响应(Response)
HTTP STATUS
200
成功返回
{
"code": "success",
"message": null,
"data": {
"createTime": "2016-12-23 15:24:21",
"etag": "BA01EF719227C7C6B4F634C1EB52F5CE",
"fileId": 988971984749344,
"length": 23440,
"name": "test.rvt",
"status": "success",
"suffix": "rvt"
}
}
| 字段 |
类型 |
描述 |
示例 |
| createTime |
String |
创建时间 |
2016-10-24 14:47:10 |
| etag |
String |
文件etag |
BA01EF719227C7C6B4F634C1EB52F5CE |
| fileId |
Number |
文件id |
988971984749344 |
| length |
Number |
文件长度 |
23440 |
| name |
String |
文件名 |
test.rvt |
| status |
String |
上传状态 |
uploading(上传中)、failed(上传失败)、success(上传完毕) |
| suffix |
String |
文件名后缀 |
rvt |
失败返回
{
"code": "file.name.invalid",
"message": "File name must not be empty."
}
错误码
| code |
说明 |
| system.error |
BIMFACE系统异常 |
| authentication.failed |
API访问合法性校验失败 |
| file.name.invalid |
文件名称不合法 |
| file.type.not.support |
文件类型不支持 |
| file.length.invalid |
文件长度太短,或超过最大限制 |
| file.not.found |
文件不存在 |
| url.invalid |
文件的下载地址不合法 |