uploading prints the download url

This commit is contained in:
2018-11-24 21:44:10 +02:00
parent d591fc35d9
commit 5d8afd5b4b
2 changed files with 29 additions and 8 deletions

View File

@@ -14,7 +14,7 @@ from utils.utils import *
from utils.crypt import *
__FLEES_VERSION__ = "20181118.0"
__FLEES_VERSION__ = "20181124.0"
app = Flask(__name__)
app.config.from_object(__name__)
config_values = read_config(app)
@@ -94,11 +94,12 @@ def upload(name = None, token = None):
if not get_or_none('upload', share) == True:
return "Upload not allowed\n",400
if file:
filename = os.path.join(
share['path'],
secure_filename_hidden(
secure_filename = secure_filename_hidden(
file.filename
)
filename = os.path.join(
share['path'],
secure_filename
)
if get_or_none('overwrite', share) == False:
if os.path.exists(filename):
@@ -116,7 +117,8 @@ def upload(name = None, token = None):
if 'from_gui' in request.form:
if request.form['from_gui'] == "true":
return redirect(url_for('list_view',name=name))
return "File uploaded\n", 200
download_url = get_download_url(share, secure_filename, token)
return "File uploaded\n%s\n"%( download_url, ), 200
else:
return "Use the 'file' variable to upload\n",400
@@ -172,7 +174,8 @@ def upload_join_splitted(name, token):
begin = uploadJoiner(target_name, parts)
except:
return "Joining failed\n", 400
return "Joining started\n", 200
download_url = get_download_url(share, request.form['filename'], token)
return "Joining started\n%s\n"%( download_url, ), 200
@app.route('/upload/url', methods=['POST'])
@@ -933,6 +936,25 @@ def zip_clean():
os.remove(os.path.join(app.config['ZIP_FOLDER'],file))
def get_download_url(share, file, token):
direct = get_or_none('direct_links', share, False)
if direct:
return request.url_root + url_for(
'download_direct',
name = share['name'],
token = get_direct_token(share, file),
filename = file
)
else:
return request.url_root + url_for(
'download_token',
name = share['name'],
filename = file,
token = token
)
if __name__ == "__main__":
zip_clean()
app.run(debug=True)

View File

@@ -90,7 +90,6 @@ _write() {
_write_file "$NAME" "$FILE"
}
}
_url "$NAME"
}
_write_folder() { # name, file
@@ -135,7 +134,7 @@ _url() { # name
}
_upload_url() {
echo "This information is a security risk, watch where it's shared"
echo "# curl -s $FLEES_ROOTURL/script/upload/$FLEES_SHARE/$FLEES_TOKEN | bash /dev/stdin file_to_upload.ext"
echo "# python2 <( curl -s $FLEES_ROOTURL/script/upload_split/$FLEES_SHARE/$FLEES_TOKEN ) file_to_upload.ext"
exit
}
_self_url() {