mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
python: document list
This commit is contained in:
@ -65,16 +65,16 @@ def getCorrectName(filename, req):
|
||||
return name
|
||||
|
||||
def getFileUri(filename, req):
|
||||
host = req.META['HTTP_REFERER'].rstrip('/')
|
||||
host = config.EXAMPLE_DOMAIN.rstrip('/')
|
||||
curAdr = req.META['REMOTE_ADDR']
|
||||
return f'{host}{settings.STATIC_URL}{curAdr}/{filename}'
|
||||
|
||||
def getCallbackUrl(filename, req):
|
||||
host = req.META['HTTP_REFERER']
|
||||
host = config.EXAMPLE_DOMAIN
|
||||
curAdr = req.META['REMOTE_ADDR']
|
||||
return f'{host}track?filename={filename}&userAddress={curAdr}'
|
||||
|
||||
def getStoragePath(filename, req):
|
||||
def getRootFolder(req):
|
||||
if isinstance(req, str):
|
||||
curAdr = req
|
||||
else:
|
||||
@ -85,8 +85,24 @@ def getStoragePath(filename, req):
|
||||
if not os.path.exists(directory):
|
||||
os.makedirs(directory)
|
||||
|
||||
return directory
|
||||
|
||||
def getStoragePath(filename, req):
|
||||
directory = getRootFolder(req)
|
||||
|
||||
return os.path.join(directory, filename)
|
||||
|
||||
|
||||
def getStoredFiles(req):
|
||||
directory = getRootFolder(req)
|
||||
|
||||
files = os.listdir(directory)
|
||||
fileInfos = []
|
||||
for f in files:
|
||||
fileInfos.append({ 'type': fileUtils.getFileType(f), 'title': f, 'url': getFileUri(f, req) })
|
||||
|
||||
return fileInfos
|
||||
|
||||
def createFile(stream, path, meta = False):
|
||||
bufSize = 8196
|
||||
with io.open(path, 'wb') as out:
|
||||
|
||||
@ -3,25 +3,25 @@ from urllib.parse import unquote
|
||||
USERS = [
|
||||
{
|
||||
'uid': 'uid-1',
|
||||
'name': 'John Smith'
|
||||
'uname': 'John Smith'
|
||||
},
|
||||
{
|
||||
'uid': 'uid-2',
|
||||
'name': 'Mark Pottato'
|
||||
'uname': 'Mark Pottato'
|
||||
},
|
||||
{
|
||||
'uid': 'uid-3',
|
||||
'name': 'Hamish Mitchell'
|
||||
'uname': 'Hamish Mitchell'
|
||||
}
|
||||
]
|
||||
|
||||
DEFAULT_USER = USERS[0]
|
||||
|
||||
def getUserFromReq(req):
|
||||
uid = unquote(req.COOKIES.get('uid'))
|
||||
uname = unquote(req.COOKIES.get('uname'))
|
||||
uid = req.COOKIES.get('uid')
|
||||
uname = req.COOKIES.get('uname')
|
||||
|
||||
if (not uid) | (not uname):
|
||||
return DEFAULT_USER
|
||||
else:
|
||||
return { 'uid': uid, 'uname': uname }
|
||||
return { 'uid': unquote(uid), 'uname': unquote(uname) }
|
||||
Reference in New Issue
Block a user