def download_file(file_id):
"""Download file
**Example request**:
.. sourcecode:: http
GET /api/1.0/files/1 HTTP/1.1
Host: do.cert.europa.eu
Accept: application/json
**Example response**:
.. sourcecode:: http
HTTP/1.0 200 OK
Content-Type: application/json
Content-Disposition: attachment; filename=CIMBL-244-EU.zip
Content-Length: 55277
Content-Type: application/zip
:param file_id: file's unique ID
:reqheader Accept: Content type(s) accepted by the client
:resheader Content-Type: this depends on `Accept` header or request
:status 200: File found
:status 404: Resource not found
"""
dfile = DeliverableFile.query.filter_by(id=file_id).first_or_404()
cfg = current_app.config
return send_file(os.path.join(cfg['APP_UPLOADS'], dfile.name),
attachment_filename=dfile.name, as_attachment=True)
评论列表
文章目录