ONLYOFFICE / DocumentServer

ONLYOFFICE Docs is a free collaborative online office suite comprising viewers and editors for texts, spreadsheets and presentations, forms and PDF, fully compatible with Office Open XML formats: .docx, .xlsx, .pptx and enabling collaborative editing in real time.
https://www.onlyoffice.com
GNU Affero General Public License v3.0
4.76k stars 1.08k forks source link

"Download failed". Is the API Doc missing a lot of information ? #2364

Closed henaff closed 1 year ago

henaff commented 1 year ago

Hi,

I loosed a day trying to integrate Onlyoffice by simply embedding an editor for one file in a react web page.

image

I didn't found any real example for document.url or editorConfig.callbackUrl values and i don't find where it is explained. The only example we have is "https://example.com/url-to-example-document.docx".

Ex: i've a file new.docx created from the server. Should it work with http://localhost/example/wopi/files/new.docx/contents ? or http://localhost/example/wopi/files/new.docx ? or http://localhost/example/editor?fileName=new.docx ? What about the callbackUrl ? Should it work with static served files ? (i tried and i also have the error) I tested with wget and it worked.

I'm totally lost while it should be the easy part...

import sign from "jwt-encode";

import { DocumentEditor } from "@onlyoffice/document-editor-react";

function EditSubreportPage() {
  const config = {
    "document": {
      "fileType": "docx",
      "key": "Khirz6zTPdfd7",
      "title": "new.docx",
      "url": "http://localhost/example/wopi/files/new.docx/contents",
    },
    "documentType": "word",
    "editorConfig": {
      "callbackUrl": "http://localhost/example/wopi/files/new.docx",
      "user": {
        "group": "Group1",
        "id": "78e1e841",
        "name": "John Smith"
      }
    },
  }

  const secret = "my_jwt_secret";
  const token = sign(config, secret);

  function log(str: string) {
    return console.log.bind(console, str);
  }

  return (
    <DocumentEditor
      id="docxEditor"
      documentServerUrl="http://localhost"
      height="900px"
      config={{
        ...config,
        token,
      }}

      events_onAppReady={log("onAppReady")}
      events_onError={log("onError")}
      events_onInfo={log("onInfo")}
    />
  )
}

export default EditSubreportPage;
DenisDeeSign commented 1 year ago

Moving this issue to DocumentServer repo, since the issue is not related to CommunityServer.