系列目錄???? 【已更新最新開(kāi)發(fā)文章,點(diǎn)擊查看詳細(xì)】
          <https://www.cnblogs.com/SavionZhang/p/11424431.html>
          在《C#開(kāi)發(fā)BIMFACE系列4 服務(wù)端API之源上傳文件》
          <https://www.cnblogs.com/SavionZhang/p/11425804.html>、《C#開(kāi)發(fā)BIMFACE系列5
          服務(wù)端API之文件直傳》 <https://www.cnblogs.com/SavionZhang/p/11425945.html>
          兩篇文章中詳細(xì)介紹了如何將本地文件上傳到BIMFACE服務(wù)器及BIMFACE后臺(tái)的分布式存儲(chǔ)系統(tǒng)中。文件上傳成功后,BIMFACE的服務(wù)會(huì)返回與該文件相關(guān)的信息,如下圖:



          ?開(kāi)發(fā)者在成功上傳了文件并獲得相關(guān)文件信息后,可以將信息保存到數(shù)據(jù)庫(kù)中供后續(xù)的業(yè)務(wù)開(kāi)發(fā)使用。

          除此之外,BIMFACE平臺(tái)還提供了單獨(dú)的服務(wù)用于獲取文件信息、獲取文件信息列表、獲取文件上傳的狀態(tài)信息、獲取應(yīng)用支持的文件類(lèi)型。

          下面分別介紹各種服務(wù)的使用方法。
          獲取文件信息
          請(qǐng)求地址:?GET https://file.bimface.com/files/{fileId}

          說(shuō)明:根據(jù)文件ID獲取文件詳細(xì)信息


          參數(shù):


          ?

          請(qǐng)求 path(示例):https://file.bimface.com/files/1419273043501216

          請(qǐng)求 header(示例):"Authorization: Bearer dc671840-bacc-4dc5-a134-97c1918d664b"

          HTTP響應(yīng)示例(200):
          { "code" : "success", "data" : { "createTime" : "2017-11-09 13:25:03", //
          文件的上傳時(shí)間"etag" : "19349858cjs98ericu989", // 存儲(chǔ)文件的額外屬性 "fileId" :
          1216113551663296, // 文件編號(hào) "length" : 39044, // 文件的大小 "name" : "-1F.rvt", //
          文件的名稱(chēng)"status" : "success", // 文件的上傳狀態(tài) "suffix" : "rvt" // 文件的后綴名 }, "message" :
          "" }
          C#實(shí)現(xiàn)方法:

          1 /// <summary> 2 /// 根據(jù)文件ID獲取文件詳細(xì)信息 3 /// </summary> 4 /// <param
          name="accessToken">令牌</param> 5 /// <param name="fileId">文件ID</param> 6 ///
          <returns></returns> 7 public virtual FileInfoGetResponse GetFileInfo(string
          accessToken,string fileId) 8 { 9 //GET https://file.bimface.com/files/{fileId}
          10 string url = string.Format(BimfaceConstants.FILE_HOST + "/files/{0}",
          fileId);11 12 BimFaceHttpHeaders headers = new BimFaceHttpHeaders(); 13
          headers.AddOAuth2Header(accessToken);14 15 try 16 { 17 FileInfoGetResponse
          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<FileInfoGetResponse>(); 24 } 25 else 26
          {27 response = new FileInfoGetResponse 28 { 29 Message = httpResult.RefText 30
          };31 } 32 33 return response; 34 } 35 catch (Exception ex) 36 { 37 throw new
          Exception("[根據(jù)文件ID獲取文件詳細(xì)信息]發(fā)生異常!", ex); 38 } 39 } 其中引用的 httpManager.Get()
          方法如下:
          /// <summary> /// HTTP-GET方法,(不包含body數(shù)據(jù))。 /// 發(fā)送 HTTP 請(qǐng)求并返回來(lái)自 Internet
          資源的響應(yīng)(HTML代碼)/// </summary> /// <param name="url">請(qǐng)求目標(biāo)URL</param> /// <returns>
          HTTP-GET的響應(yīng)結(jié)果</returns> public HttpResult Get(string url) { return
          RequestString(url,null, HttpMethod.GET, null); } 1 /// <summary> 2 ///
          HTTP請(qǐng)求(包含文本的body數(shù)據(jù)) 3 /// </summary> 4 /// <param name="url">請(qǐng)求目標(biāo)URL</param> 5
          /// <param name="data">
          主體數(shù)據(jù)(普通文本或者JSON文本)。如果參數(shù)中有中文,請(qǐng)使用合適的編碼方式進(jìn)行編碼,例如:gb2312或者utf-8</param> 6 ///
          <param name="method">請(qǐng)求的方法。請(qǐng)使用 HttpMethod 的枚舉值</param> 7 /// <param
          name="contentType"><see langword="Content-type" /> HTTP 標(biāo)頭的值。請(qǐng)使用 ContentType
          類(lèi)的常量來(lái)獲取</param> 8 /// <returns></returns> 9 private HttpResult RequestString(
          string url, string data, string method, string contentType) 10 { 11 HttpResult
          httpResult =new HttpResult(); 12 HttpWebRequest httpWebRequest = null; 13 14 try
          15 { 16 httpWebRequest = WebRequest.Create(url) as HttpWebRequest; 17
          httpWebRequest.Method = method; 18 httpWebRequest.Headers = HeaderCollection; 19
          httpWebRequest.CookieContainer = CookieContainer; 20 if (!string
          .IsNullOrWhiteSpace(contentType))21 { 22 httpWebRequest.ContentType =
          contentType;//
          此屬性的值存儲(chǔ)在WebHeaderCollection中。如果設(shè)置了WebHeaderCollection,則屬性值將丟失。所以放置在Headers
          屬性之后設(shè)置 23 } 24 httpWebRequest.UserAgent = _userAgent; 25
          httpWebRequest.AllowAutoRedirect = _allowAutoRedirect; 26
          httpWebRequest.ServicePoint.Expect100Continue =false; 27 28 if (data != null) 29
          {30 httpWebRequest.AllowWriteStreamBuffering = true; 31 using (Stream
          requestStream = httpWebRequest.GetRequestStream()) 32 { 33
          requestStream.Write(EncodingType.GetBytes(data),0, data.Length);//將請(qǐng)求參數(shù)寫(xiě)入請(qǐng)求流中 34
          requestStream.Flush();35 } 36 } 37 38 HttpWebResponse httpWebResponse =
          httpWebRequest.GetResponse()as HttpWebResponse; 39 if (httpWebResponse != null)
          40 { 41 GetResponse(ref httpResult, httpWebResponse); 42
          httpWebResponse.Close();43 } 44 } 45 catch (WebException webException) 46 {
          47 GetWebExceptionResponse(ref httpResult, webException); 48 } 49 catch
          (Exception ex)50 { 51 GetExceptionResponse(ref httpResult, ex, method,
          contentType);52 } 53 finally 54 { 55 if (httpWebRequest != null) 56 { 57
          httpWebRequest.Abort();58 } 59 } 60 61 return httpResult; 62 } 測(cè)試
          ?在BIMFACE的控制臺(tái)中可以看到我們上傳的文件列表

          選擇任意一個(gè)文件的ID來(lái)做測(cè)試

          可以看到獲取文件信息成功,返回了以下信息:文件的上傳時(shí)間、存儲(chǔ)文件的額外屬性、文件編號(hào)、文件的大小、文件的名稱(chēng)、文件的上傳狀態(tài)、文件的后綴名。
          測(cè)試程序如下: 1 // 獲取文件信息 2 protected void btnGetFileInfo_Click(object sender,
          EventArgs e) 3 { 4 txtFileInfo.Text = string.Empty; 5 6 string token =
          txtAccessToken.Text; 7 string fileId = txtFileId.Text; 8 9 FileApi api = new
          FileApi();10 FileInfoGetResponse response = api.GetFileInfo(token, fileId); 11
          12 txtFileInfo.Text = response.Code 13 + Environment.NewLine 14 +
          response.Message15 + Environment.NewLine 16 + response.Data.ToString(); 17 }
          系列目錄????【已更新最新開(kāi)發(fā)文章,點(diǎn)擊查看詳細(xì)】 <https://www.cnblogs.com/SavionZhang/p/11424431.html>

          友情鏈接
          ioDraw流程圖
          API參考文檔
          OK工具箱
          云服務(wù)器優(yōu)惠
          阿里云優(yōu)惠券
          騰訊云優(yōu)惠券
          京東云優(yōu)惠券
          站點(diǎn)信息
          問(wèn)題反饋
          郵箱:[email protected]
          QQ群:637538335
          關(guān)注微信

                女人脱了内裤让男生桶爽免费网站 | 精品无码黑人又粗又大又长 | 大乳boobs巨大乳bbw | 99re国产这里只有精品6 | 一级a一级a爰片免费免水l软件 |