How do I download files from my gridFS store in Mongodb?
I have the following code:
@bottle.route('/download')
def download():
file_id = ObjectId(bottle.request.query.id)
if file_id:
try:
file_to_download = fs.get(file_id)
except:
return "document id not found for id:" + file_id, sys.exc_info()[0]
return (file_to_download)
return bottle.template('files_test/download')
which returns gibberish in the browser. How do I specify that I want it to be downloaded?
Edit:
This is the hyperlink I want to use to download the file:
<a href="download?id={{fileobj['_id']}}"><--Download File--></a>
Have I missed it here well?