1

我正在尝试为存储在本地文件系统中的文件实现预览(WOPI)。我正在尝试使用我们拥有的 Office Online Server Farm 来实现它。我使用了下面的代码,但它调用了“Get”端点,但之后它没有调用“contents”端点。

网址 -http://ServerName/wv/wordviewerframe.aspx?ui=1033&rs=1033&dchat=false&hid=1&IsLicensedUser=1&WOPISrc=http://WOPIHost:8082/wopi/files/00000000-0000-0000-0000-000000000000&access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6InhYbFQwSUp4MlZCVEJFeVFMdGtFOFY2ZkhwZyJ9%%2EXmvaQMvtq0ClU1rHW%5FibIx7OjQ7nbmXVO9Bs3JmH%2DCqxdxtaJKKqC9sd3j2cjfFIIsYFw%2DOpoZ6rpp5ijcl3WwWJWX0uR%2DsgdAi4If49dQnbDDunvLdCuKl%2D7PFc96M60ByVa0jbywUvFW8FhoR2bPdVMBYiILC5oExEkOc4BCGgWoUNE9n%2Dv74fWJrFbJFtMVaof3n%2DQCQHy8SXh%5F3O2SaSVw9bMPYdELSbPnvqsz4l8mUrEbN%2Dhs3kW2n3d1nSuhjcEn8JyMZUrFk%5Fxl2GEbGh8A2KavTql1W5MBlXPzL2r4Ynn1A3XTguYcsieF%5FORhCemm%5FMFbDGMgUvlb%2Dkwg&access_token_ttl=1583752281063

    {
        [WopiTokenValidationFilter]
        [HttpGet]
        [Route("wopi/files/{id}")]
        public async Task<HttpResponseMessage> Get(Guid id)
        {
            //Handles CheckFileInfo
            return await HttpContext.Current.ProcessWopiRequest();
        }

        [WopiTokenValidationFilter]
        [HttpGet]
        [Route("wopi/files/{id}/contents")]
        public async Task<HttpResponseMessage> Contents(Guid id)
        {
            //Handles GetFile
            return await HttpContext.Current.ProcessWopiRequest();
        }

        [WopiTokenValidationFilter]
        [HttpPost]
        [Route("wopi/files/{id}")]
        public async Task<HttpResponseMessage> Post(Guid id)
        {
            //Handles Lock, GetLock, RefreshLock, Unlock, UnlockAndRelock, PutRelativeFile, RenameFile, PutUserInfo
            return await HttpContext.Current.ProcessWopiRequest();
        }

        [WopiTokenValidationFilter]
        [HttpPost]
        [Route("wopi/files/{id}/contents")]
        public async Task<HttpResponseMessage> PostContents(Guid id)
        {
            //Handles PutFile
            return await HttpContext.Current.ProcessWopiRequest();
        }
    }``` 
4

2 回答 2

1

最后我确定了这个问题。Version 字段应该是类似“1.0.0.0”的字符串,而不是 int。

于 2020-03-20T10:46:12.820 回答
0

这是回应 -{"UserId":"user@domain.com","CloseUrl":"https://<server>:8082","HostEditUrl":"http://<server>/we/wordeditorframe.aspx?ui=1033&rs=1033&dchat=false&hid=1&IsLicensedUser=1&WOPISrc=http://<server>:8082/wopi/files/00000000-0000-0000-0000-000000000000","HostViewUrl":"http://<server>/wv/wordviewerframe.aspx?ui=1033&rs=1033&dchat=false&hid=1&IsLicensedUser=1&WOPISrc=http://<server>:8082/wopi/files/00000000-0000-0000-0000-000000000000","SupportsCoauth":false,"SupportsExtendedLockLength":false,"SupportsFileCreation":false,"SupportsFolders":false,"SupportsGetLock":true,"SupportsLocks":true,"SupportsRename":true,"SupportsScenarioLinks":false,"SupportsSecureStore":false,"SupportsUpdate":true,"SupportsUserInfo":true,"LicensesCheckForEditIsEnabled":true,"ReadOnly":false,"RestrictedWebViewOnly":false,"UserCanAttend":false,"UserCanNotWriteRelative":false,"UserCanPresent":false,"UserCanRename":true,"UserCanWrite":true,"WebEditingDisabled":false,"Actions":null,"id":"00000000-0000-0000-0000-000000000000","LockValue":null,"LockExpires":null,"OwnerId":"user@domain.com","BaseFileName":"Test.docx","Container":null,"Size":102400,"Version":1,"UserInfo":null}

于 2020-03-16T08:14:02.657 回答