2016-06-24 152 views
0

我已經爲WOPI客戶端(即Office Online)實現了putFile端點 單擊編輯文檔按鈕時,第一個請求應該發送到WOPI客戶端?WOPI編輯文檔

我已經稱爲繼上編輯鏈接網址:

POST https://word-edit.officeapps-df.live.com/we/wordviewerframe.aspx?WOPISrc=https://domain/WOPI_IntegrationDemo/wopi/files/Sample_application_content3.docx/ 

但文件說,它會首先執行鎖定請求。這究竟意味着什麼?

回答

0

從你的問題我明白你正在實施一個WOPI主機。該URL看起來非常好 - 只要確保WOPISrc參數已被轉義並且包含access_token參數。

當您單擊URL時,您將指示WOPI客戶端(OO/OWA)從WOPI主機加載由WOPISrc定義的字段。

WOPI客戶端通常會首先嚐試從WOPI主機獲取鎖(獨佔寫訪問)。爲了這些目的,您應該根據documentation在WOPI主機中執行LOCK操作。

0

首先,您必須爲此 添加Access令牌,然後嘗試對其進行編輯調用 1.get file info。獲取[路線(「文件/ {名稱} /」)] 2.post文件。 Post [路由(「文件/ {名稱} /」)] 聽說你必須實現對鎖定文件的響應Cobalt請求 var response = new HttpResponseMessage(HttpStatusCode.OK); (xWopiOverride ==「LOCK」|| string.Equals(xWopiOverride,「UNLOCK」)) {0}對於docx,xl​​sx和pptx response = new HttpResponseMessage(HttpStatusCode.OK); } 否則如果(string.Equals(xWopiOverride, 「鈷」)) { //鈷,對於DOCX和PPTX

   EditSession editSession = EditSessionManager.Instance.GetSession(access_token); 
       if (editSession == null) 
       { 
        editSession = new FileSession(access_token, fileInfo, matterInfo, dpsUserName, databaseInfo, string.Empty, string.Empty, string.Empty, false); 
        EditSessionManager.Instance.AddSession(editSession); 
       } 

       var memoryStream = new MemoryStream(); 
       HttpContext.Current.Request.InputStream.CopyTo(memoryStream); 
       var atomFromByteArray = new AtomFromByteArray(memoryStream.ToArray()); 

       ProtocolVersion protocolVersion; 
       object context; 
       var requestBatch = new RequestBatch(); 
       requestBatch.DeserializeInputFromProtocol(atomFromByteArray, out context, out protocolVersion); 
       editSession.ExecuteRequestBatch(requestBatch); 

       foreach (var request in requestBatch.Requests) 
       { 
        if (request.GetType() == typeof(PutChangesRequest) && request.PartitionId == FilePartitionId.Content) 
        { 
         editSession.Save(); 
         break; 
        } 
       } 

       var responseContent = requestBatch.SerializeOutputToProtocol(protocolVersion, context); 
       var correlationId = Request.Headers.GetValues("X-WOPI-CorrelationID").First(); 

       response.Headers.Add("X-WOPI-CorrelationID", correlationId); 
       response.Headers.Add("request-id", correlationId); 

       var pushStreamContent = new PushStreamContent((outputStream, httpContext, transportContent) => 
       { 
        responseContent.CopyTo(outputStream); 
        outputStream.Close(); 
       }); 

       response.Content = pushStreamContent; 
       response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); 
       response.Content.Headers.ContentLength = responseContent.Length; 
      } 
      return response; 
+0

休耕此https://github.com/petrsvihlik/WopiHost –