Improve encrypt command line interface, add progress bar

This commit is contained in:
jaseg 2019-06-26 16:36:20 +09:00
parent fb2f3bcc2a
commit bf86e740bd
3 changed files with 58 additions and 24 deletions

View file

@ -8,6 +8,7 @@ from flask import Flask, abort, request, Response
import filecrypt
app = Flask(__name__)
app.config.from_envvar('SECURE_DOWNLOAD_SETTINGS')
BASE64_RE = re.compile('^[A-Za-z0-9+-_]+=*$')
@app.route('/<file_id>/<token>/<filename>')
@ -17,7 +18,7 @@ def download(file_id, token, filename):
if not BASE64_RE.match(token) or len(token) != filecrypt.TOKEN_LENGTH:
abort(400, 'Invalid token format')
path = f'{file_id}.enc'
path = f'{app.config["SERVE_PATH"]}/{file_id}.enc'
if not os.path.isfile(path):
abort(403) # forbidden