mirror of
https://github.com/koniu/recoll-webui.git
synced 2025-10-03 17:59:50 +02:00
Merge pull request #13 from medoc92/master
Chose appropriate file name and extension for downloading a subdocument
This commit is contained in:
commit
0817886f15
1 changed files with 4 additions and 3 deletions
7
webui.py
7
webui.py
|
@ -294,16 +294,17 @@ def edit(resnum):
|
||||||
rclq.scroll(resnum)
|
rclq.scroll(resnum)
|
||||||
doc = rclq.fetchone()
|
doc = rclq.fetchone()
|
||||||
bottle.response.content_type = doc.mimetype
|
bottle.response.content_type = doc.mimetype
|
||||||
bottle.response.headers['Content-Disposition'] = \
|
|
||||||
'attachment; filename=%s' % doc.filename
|
|
||||||
# If ipath is null, we can just return the file
|
|
||||||
pathismine = False
|
pathismine = False
|
||||||
if doc.ipath == '':
|
if doc.ipath == '':
|
||||||
|
# If ipath is null, we can just return the file
|
||||||
path = doc.url.replace('file://','')
|
path = doc.url.replace('file://','')
|
||||||
else:
|
else:
|
||||||
|
# Else this is a subdocument, extract to temporary file
|
||||||
xt = rclextract.Extractor(doc)
|
xt = rclextract.Extractor(doc)
|
||||||
path = xt.idoctofile(doc.ipath, doc.mimetype)
|
path = xt.idoctofile(doc.ipath, doc.mimetype)
|
||||||
pathismine = True
|
pathismine = True
|
||||||
|
bottle.response.headers['Content-Disposition'] = \
|
||||||
|
'attachment; filename=%s' % os.path.basename(path)
|
||||||
print >> sys.stderr, "Sending %s with mimetype %s" % (path, doc.mimetype)
|
print >> sys.stderr, "Sending %s with mimetype %s" % (path, doc.mimetype)
|
||||||
f = open(path, 'r')
|
f = open(path, 'r')
|
||||||
if pathismine:
|
if pathismine:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue