from flask import (current_app, send_from_directory) from hashlib import sha1 from pathlib import Path import os def save(name, content): h = sha1(content).hexdigest() filename = h + Path(name).suffix file_path = os.path.join(current_app.config['UPLOAD_FOLDER'], filename) with open(file_path, "wb") as file: file.write(content) return filename def get(name): return send_from_directory(current_app.config['UPLOAD_FOLDER'], name)