direct url extract for flip

This commit is contained in:
2018-08-21 14:56:56 +03:00
parent 2c67bc2ca6
commit 020bb20327
2 changed files with 26 additions and 19 deletions

View File

@@ -358,22 +358,23 @@ def file_delete(name, token, filename):
return "OK", 200
#~ @app.route('/file/direct/<name>/<token>/<path:filename>', methods=['GET'])
#~ def file_direct(name, token, filename):
#~ (ok,share) = get_share(name, token = token)
#~ if not ok:
#~ return share
#~ full_path = os.path.join(
#~ share['path'],
#~ secure_filename_hidden(filename)
#~ )
#~ if not os.path.exists(full_path):
#~ return "-1", 403
#~ allow_direct = get_or_none('direct_links', share) if get_or_none('pass_hash', share) else False
#~ if not allow_direct:
#~ return "-1", 403
#~ token = get_direct_token(share, filename)
#~ return token, 200
@app.route('/file/direct/<name>/<token>/<path:filename>', methods=['GET'])
def file_direct(name, token, filename):
(ok,share) = get_share(name, token = token)
if not ok:
return share
full_path = os.path.join(
share['path'],
secure_filename_hidden(filename)
)
if not os.path.exists(full_path):
return "-1", 403
allow_direct = get_or_none('direct_links', share) if get_or_none('pass_hash', share) else False
if not allow_direct:
return "-1", 403
token = get_direct_token(share, filename)
url = url_for('download_direct', name = name, token = token, filename = filename )
return app.config['PUBLIC_URL'] + url, 200
@app.route('/file/ls/<name>/<token>', methods=['GET'])