Skip to content

Commit

Permalink
try to link to onlyoffice
Browse files Browse the repository at this point in the history
  • Loading branch information
lovehunter9 committed Nov 8, 2024
1 parent cfefb42 commit 3407eff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions seahub/onlyoffice/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from seaserv import seafile_api

from seahub.base.templatetags.seahub_tags import email2nickname, email2contact_email
from seahub.utils import get_file_type_and_ext, gen_file_get_url, \
from seahub.utils import get_file_type_and_ext, gen_file_get_url_onlyoffice, \
get_site_scheme_and_netloc_onlyoffice

from seahub.onlyoffice.models import OnlyOfficeDocKey
Expand Down Expand Up @@ -135,7 +135,7 @@ def get_onlyoffice_dict(request, username, repo_id, file_path, file_id='',

# for render onlyoffice html
file_name = os.path.basename(file_path.rstrip('/'))
doc_url = gen_file_get_url(dl_token, file_name)
doc_url = gen_file_get_url_onlyoffice(dl_token, file_name)

base_url = get_site_scheme_and_netloc_onlyoffice()
logger.info(f"base_url={base_url}")
Expand Down
15 changes: 15 additions & 0 deletions seahub/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ def get_fileserver_root():
"""
return config.FILE_SERVER_ROOT

def get_fileserver_root_onlyoffice():
""" Construct seafile fileserver address and port.
Returns:
Constructed fileserver root.
"""
return config.ONLYOFFICE_FILE_SERVER_ROOT

def get_inner_fileserver_root():
"""Construct inner seafile fileserver address and port.
Expand Down Expand Up @@ -507,6 +515,13 @@ def gen_file_get_url(token, filename):
"""
return '%s/files/%s/%s' % (get_fileserver_root(), token, quote(filename))

def gen_file_get_url_onlyoffice(token, filename):
"""
Generate fileserver file url.
Format: http://<domain:port>/files/<token>/<filename>
"""
return '%s/files/%s/%s' % (get_fileserver_root_onlyoffice(), token, quote(filename))

def gen_file_upload_url(token, op, replace=False):
url = '%s/%s/%s' % (get_fileserver_root(), op, token)
if replace is True:
Expand Down

0 comments on commit 3407eff

Please sign in to comment.