1
0
Fork 0
mirror of https://github.com/koniu/recoll-webui.git synced 2025-10-03 01:39:22 +02:00

chose appropriate file name extension for downloading a subdocument

This commit is contained in:
Jean-Francois Dockes 2013-09-14 20:04:04 +02:00
parent c11608b668
commit a1e79dc48c

View file

@ -294,16 +294,17 @@ def edit(resnum):
rclq.scroll(resnum)
doc = rclq.fetchone()
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
if doc.ipath == '':
# If ipath is null, we can just return the file
path = doc.url.replace('file://','')
else:
# Else this is a subdocument, extract to temporary file
xt = rclextract.Extractor(doc)
path = xt.idoctofile(doc.ipath, doc.mimetype)
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)
f = open(path, 'r')
if pathismine: