I am running document server with docker on a remote server(IP is 172.25.161.211):
docker run -i -t -d -p 80:80 onlyoffice/documentserver
the test example also been installed.
I am developing some web app to integrate with document server, which upload some docx file to the example, and then open a editor failed with “Download failed”, docker logs:
[2021-12-01T03:29:28.018] [ERROR] nodeJS - error downloadFile:url=http://172.25.161.211/example/download?fileName=a7d8f8de-05b8-4ec0-bd4e-0fb349132fc2.docx;attempt=3;code:null;connect:null;(id=Khirz6zTPdfd7)
Error: Error response: statusCode:500; headers:{"server":"nginx","date":"Wed, 01 Dec 2021 03:29:28 GMT","content-type":"text/html; charset=utf-8","content-length":"1095","connection":"keep-alive","x-powered-by":"Express","access-control-allow-origin":"*","etag":"W/\"447-PnbTeHgVWSyG80CT8TiPTuVOxcs\""}; body:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<!--
*
* (c) Copyright Ascensio System SIA 2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
-->
<title>Error</title>
</head>
<body>
<hgroup>
<h1>Error.</h1>
<h2>An error occurred while processing your request.</h2>
</hgroup>
<div>ENOENT: no such file or directory, stat '/var/lib/onlyoffice/documentserver-example/files/172.17.0.1/a7d8f8de-05b8-4ec0-bd4e-0fb349132fc2.docx'</div>
</body>
</html>
at Request._callback (/snapshot/server/build/server/Common/sources/utils.js:0:0)
at Request.init.self.callback (/snapshot/server/build/server/Common/node_modules/request/request.js:185:22)
at Request.emit (events.js:198:13)
at Request.<anonymous> (/snapshot/server/build/server/Common/node_modules/request/request.js:1154:10)
at Request.emit (events.js:198:13)
at IncomingMessage.<anonymous> (/snapshot/server/build/server/Common/node_modules/request/request.js:1076:12)
at Object.onceWrapper (events.js:286:20)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
[xwiki@VM_161_211_centos ~]$ docker exec -it 1b16 /bin/bash
root@1b16a5c7890f:/# ls /var/lib/onlyoffice/documentserver-example/files
172.17.0.1 172.30.7.4
root@1b16a5c7890f:/# ls /var/lib/onlyoffice/documentserver-example/files/172.30.7.4/
a7d8f8de-05b8-4ec0-bd4e-0fb349132fc2.docx a7d8f8de-05b8-4ec0-bd4e-0fb349132fc2.docx-history b3d3e606-bf5f-43e8-ae9d-6419353e346e.docx b3d3e606-bf5f-43e8-ae9d-6419353e346e.docx-history
172.30.7.4
is my local machine’s IP, but the document server is trying to find uploaded file in folder 172.17.0.1
seems the test example store uploaded file in folder named as client’s ip, how to specify the document.url
then ?
my code:
const openDoc = function (body, node, file) {
const url = 'http://172.25.161.211/example/upload'
const DOC_NAME = uuid() + '.docx'
console.log(file)
console.log('upload to oo as file ' + DOC_NAME)
var formdata = new FormData()
formdata.append('uploadedFile', file, DOC_NAME)
formdata.append('fileName', DOC_NAME)
var requestOptions = {
method: 'POST',
body: formdata,
redirect: 'follow'
}
fetch(url, requestOptions)
.then((res) => {
const script = document.createElement('script')
script.id = ''
script.append(`
config = {
document: {
fileType: 'docx',
key: 'Khirz6zTPdfd7',
title: '${DOC_NAME}',
url: 'http://172.25.161.211/example/download?fileName=${DOC_NAME}'
},
documentType: 'word'
}
var docEditor = new DocsAPI.DocEditor('${node.id}', config)`)
body.appendChild(script)
})
.catch((err) => {
console.error(err)
})
}