系列目录     【已更新最新开发文章,点击查看详细】
<https://www.cnblogs.com/SavionZhang/p/11424431.html>

在BIMFACE控制台上传文件,上传过程及结束后它会自动告诉你文件的上传状态,目前有三种状态:uploading,success,failure。即上传中、上传成功、上传失败。

如果是通过调用服务接口来上传文件,上传结束后也可以再调用BIMFACE提供的“获取文件上传状态信息”接口来查询状态。

下面详细介绍如何获取文件上传状态信息。

请求地址:GET https://file.bimface.com/files/{fileId}/uploadStatus

说明:根据文件ID获取文件上传状态信息

参数:




请求 path(示例):https://file.bimface.com/files/1419273043501216/uploadStatus

请求 header(示例):"Authorization: Bearer dc671840-bacc-4dc5-a134-97c1918d664b"

HTTP响应示例(200):
{ "code" : "success", "data" : { "failedReason" : "input.stream.read.error",
// 上传失败的远因。如果上传成功,则为空。"fileId" : 1216113551663296, // 文件ID "name" : "-1F.rvt",
// 文件名称"status" : "failure" // 文件上传状态 }, "message" : "" }
C#实现方法:
1 /// <summary> 2 /// 获取文件上传状态信息 3 /// </summary> 4 /// <param
name="accessToken">令牌</param> 5 /// <param name="fileId">文件ID</param> 6 ///
<returns></returns> 7 public virtual FileUploadStatusResponse
GetFileUploadStatus(string accessToken, string fileId) 8 { 9 //GET
https://file.bimface.com/files/{fileId}/uploadStatus 10 string url = string
.Format(BimfaceConstants.FILE_HOST +"/files/{0}/uploadStatus", fileId); 11 12
BimFaceHttpHeaders headers =new BimFaceHttpHeaders(); 13
headers.AddOAuth2Header(accessToken);14 15 try 16 { 17
FileUploadStatusResponse response;18 19 HttpManager httpManager = new
HttpManager(headers);20 HttpResult httpResult = httpManager.Get(url); 21 if
(httpResult.Status == HttpResult.STATUS_SUCCESS) 22 { 23 response =
httpResult.Text.DeserializeJsonToObject<FileUploadStatusResponse>(); 24 } 25
else 26 { 27 response = new FileUploadStatusResponse 28 { 29 Message =
httpResult.RefText30 }; 31 } 32 33 return response; 34 } 35 catch (Exception
ex)36 { 37 throw new Exception("[获取文件上传状态信息]发生异常!", ex); 38 } 39 } 其中引用的
httpManager.Get() 方法,请参考《C#开发BIMFACE系列6 服务端API之获取文件信息》
<https://www.cnblogs.com/SavionZhang/p/11433179.html>,方法完全一样。 测试
 在BIMFACE的控制台中可以看到我们上传的文件列表


选择任意一个文件的ID来做测试



可以看到获取文件上传状态信息成功,返回了以下信息:失败原因、文件编号、文件的名称、文件的上传状态。

测试程序如下:
// 获取文件上传状态信息 protected void btnGetFileUploadStatus_Click(object sender,
EventArgs e) { txtFileInfo.Text= string.Empty; string token =
txtAccessToken.Text;string fileId = txtFileId.Text; FileApi api = new
FileApi(); FileUploadStatusResponse response= api.GetFileUploadStatus(token,
fileId); txtFileInfo.Text= response.Code + Environment.NewLine +
response.Message+ Environment.NewLine + response.Data.ToString(); } 系列目录    
【已更新最新开发文章,点击查看详细】 <https://www.cnblogs.com/SavionZhang/p/11424431.html>

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:637538335
关注微信