发起文件转换_文档_BIMFACE_BIM应用二次开发平台

API:发起文件转换

PUT  https://api.bimface.com/translate

文件上传成功后,即可发起对该文件的转换。由于转换不能立即完成,BIMFace支持在文件转换完成以后,通过Callback机制通知应用;另外,应用也可以通过接口查询转换状态。


请求(Request)

Header
key value 示例
Authorization bearer {accessToken} bearer xxxx-xxxx-xxxx-xxxx
Content-Type application/json
Url Parameter

Request Body
常规场景
{
    "source":{
        "fileId":857482189666208,
        "compressed":false,
        "rootName":"root.rvt"
    },
    "priority":2,
    "callback":"http://www.app.com/receive",
    "config":null
}
使用模型内置材质场景
{
    "source":{
        "fileId":857482189666208,
        "compressed":false,
        "rootName":"root.rvt"
    },
    "priority":2,
    "callback":"http://www.app.com/receive",
    "config":{"texture":true}
}
使用模型外部材质场景(上传的文件必须为压缩包,压缩包内同级目录包含模型文件和关联的所有材质文件,转换时必须指定rootName为主文件)
{
    "source":{
        "fileId":1234621112557376,
        "compressed":true,
        "rootName":"bimface_2018_打包材质&系统材质库.rvt"
    },
    "priority":2,
    "callback":"http://www.app.com/receive",
    "config":{"texture":true}
}
字段 类型 必填 描述 示例
fileId Number Y 文件Id,即调用上传文件API返回的fileId 857482189666208
compressed Boolean N 是否为压缩文件,默认为false true, false
rootName String N 如果是压缩文件,必须指定压缩包中哪一个是主文件 root.rvt
priority Number 优先级,数字越大,优先级越低 1, 2, 3
callback String N Callback地址,待转换完毕以后,BIMFace会回调该地址 http://www.app.com/receive
config Json Object N 转换引擎自定义参数,config参数跟转换引擎相关,不同的转换引擎支持不同的config格式。例如转换时添加内置材质,则添加参数值{“texture”:true},添加外部材质时参考“使用模型外置材质场景”请求报文 {“texture”:true}
curl -X PUT 
-H "Authorization: bearer <your accessToken>" 
-H "Content-Type: application/json" 
-d '{ {"fileId":<your fileId>, "compressed":<true or false>,"rootName":<your rootName>}, "callback":"<your callback url>"}' 
"https://api.bimface.com/translate"

响应(Response)

HTTP STATUS

200

{
	"code": "success",
	"message": null,
	"data": {
	    "createTime": "2016-12-21 16:11:20",
	    "fileId": 987579504853792,
	    "name": "1234.rvt",
	    "priority": 2,
	    "reason": null,
	    "status": "proccessing",
	    "thumbnail": null
	}
}
字段 类型 描述 示例
fileId Number 文件Id 857482189666208
name String 文件名称 abc.rvt
status String 转换状态 prepare(待转换)、processing(转换中)、success(转换成功)、failed(转换失败)
priority Number 转换任务优先级 2
thumbnail String[] 缩略图地址
reason String 若转换失败,返回失败原因
createTime String 转换开始时间,格式:yyyy-MM-dd hh:mm:ss 2016-10-14 14:29:16
失败返回
{
    "code": "authentication.failed",
    "message": "Token was not recognized."
}
错误码
code 说明
system.error BIMFace系统异常
authentication.failed API访问合法性校验失败
file.not.found 待转文件不存在
file.not.complete 待转文件未上传成功
file.upload.failed 待转文件上传失败
url.invalid 回调地址不是正确的URL
priority.not.support 不支持输入的优先级

回调(Callback)

待BIMFace转换完毕后,根据应用传入的回调地址,BIMFace会通知转换结果,转换可能成功、也可能失败。

Method

GET

Header
key value 示例
Content-Type application/json
Url Parameter
字段 类型 描述 示例
fileId Number 文件ID 857482189666208
status String 转换的结果 success(转换成功)、failed(转换失败)
reason String 若转换失败,则返回失败原因
thumbnail String 缩略图地址
nonce String 回调随机数
signature String 签名

signature(签名):为了确保回调消息是由BIMFace发出的,应用在收到回调消息后,须验证签名。签名的计算方式:MD5(“appKey:appSecret:fileId:status:nonce”),如果应用计算的签名与BIMFace返回的签名一致,则证明该消息是安全可靠的。

消息回执

应用收到回调后,须向BIMFace发送回执,回执消息:HTTP STATUS 200