首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WOPI编辑文档

WOPI编辑文档
EN

Stack Overflow用户
提问于 2016-06-24 17:52:56
回答 2查看 1K关注 0票数 0

我已经为WOPI客户端(即Office Online)实现了putFile端点,单击“编辑文档”按钮时,应该向WOPI客户端发出什么第一个请求?

我在编辑链接上调用了以下URL:

代码语言:javascript
复制
POST https://word-edit.officeapps-df.live.com/we/wordviewerframe.aspx?WOPISrc=https://domain/WOPI_IntegrationDemo/wopi/files/Sample_application_content3.docx/

但是文档说它将首先执行一个锁请求。这到底是什么意思?

EN

回答 2

Stack Overflow用户

发布于 2016-06-27 20:36:18

根据您的问题,我了解到您正在实现一个WOPI主机。URL看起来还不错--只要确保WOPISrc参数被转义并且包含access_token参数即可。

当您单击URL时,您将指示WOPI客户端(OO/OWA)从WOPI主机加载由WOPISrc定义的字段。

WOPI客户端通常首先尝试从WOPI主机获取锁(独占写访问)。出于这些目的,您应该根据documentation在您的WOPI主机中实现锁定操作。

票数 0
EN

Stack Overflow用户

发布于 2016-06-29 13:10:29

首先,你必须为此添加访问令牌,然后尝试对其进行word编辑,调用1.get file info。获取Route("files/{name}/") 2.post文件。在hear中发布路由(“files /{name}/”)你必须为锁定文件实现响应Cobalt Request var response = new HttpResponseMessage(HttpStatusCode.OK);if (xWopiOverride == " Lock“|| string.Equals(xWopiOverride,"UNLOCK")) {//对于docx,xlsx和pptx response = new HttpResponseMessage(HttpStatusCode.OK);} else if (string.Equals(xWopiOverride,“钴”)){//钴,适用于docx和pptx

代码语言:javascript
复制
                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
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38010507

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档