79256521

Date: 2024-12-05 23:48:06
Score: 0.5
Natty:
Report link

Adding os.path.abspath to the send_file request fixes the issue for me by making the send_file request pull from the first folder location described in my question.

The second endpoint becomes:

@app.route('/get/<string:name>', methods=['GET'])
def get(name: str):
    saved_file: SavedFile = SavedFile.query.filter_by(filename=name).first()

    path = os.path.join(current_app.config['UPLOAD_FOLDER'], saved_file.filename)
    
    return send_file(os.path.abspath(path), as_attachment=True)
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Nicolas Gatien