uploading prints the download url
This commit is contained in:
34
code/app.py
34
code/app.py
@@ -14,7 +14,7 @@ from utils.utils import *
|
|||||||
from utils.crypt import *
|
from utils.crypt import *
|
||||||
|
|
||||||
|
|
||||||
__FLEES_VERSION__ = "20181118.0"
|
__FLEES_VERSION__ = "20181124.0"
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.from_object(__name__)
|
app.config.from_object(__name__)
|
||||||
config_values = read_config(app)
|
config_values = read_config(app)
|
||||||
@@ -94,11 +94,12 @@ def upload(name = None, token = None):
|
|||||||
if not get_or_none('upload', share) == True:
|
if not get_or_none('upload', share) == True:
|
||||||
return "Upload not allowed\n",400
|
return "Upload not allowed\n",400
|
||||||
if file:
|
if file:
|
||||||
|
secure_filename = secure_filename_hidden(
|
||||||
|
file.filename
|
||||||
|
)
|
||||||
filename = os.path.join(
|
filename = os.path.join(
|
||||||
share['path'],
|
share['path'],
|
||||||
secure_filename_hidden(
|
secure_filename
|
||||||
file.filename
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
if get_or_none('overwrite', share) == False:
|
if get_or_none('overwrite', share) == False:
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
@@ -116,7 +117,8 @@ def upload(name = None, token = None):
|
|||||||
if 'from_gui' in request.form:
|
if 'from_gui' in request.form:
|
||||||
if request.form['from_gui'] == "true":
|
if request.form['from_gui'] == "true":
|
||||||
return redirect(url_for('list_view',name=name))
|
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:
|
else:
|
||||||
return "Use the 'file' variable to upload\n",400
|
return "Use the 'file' variable to upload\n",400
|
||||||
|
|
||||||
@@ -172,7 +174,8 @@ def upload_join_splitted(name, token):
|
|||||||
begin = uploadJoiner(target_name, parts)
|
begin = uploadJoiner(target_name, parts)
|
||||||
except:
|
except:
|
||||||
return "Joining failed\n", 400
|
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'])
|
@app.route('/upload/url', methods=['POST'])
|
||||||
@@ -933,6 +936,25 @@ def zip_clean():
|
|||||||
os.remove(os.path.join(app.config['ZIP_FOLDER'],file))
|
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__":
|
if __name__ == "__main__":
|
||||||
zip_clean()
|
zip_clean()
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ _write() {
|
|||||||
_write_file "$NAME" "$FILE"
|
_write_file "$NAME" "$FILE"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_url "$NAME"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_write_folder() { # name, file
|
_write_folder() { # name, file
|
||||||
@@ -135,7 +134,7 @@ _url() { # name
|
|||||||
}
|
}
|
||||||
_upload_url() {
|
_upload_url() {
|
||||||
echo "This information is a security risk, watch where it's shared"
|
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
|
exit
|
||||||
}
|
}
|
||||||
_self_url() {
|
_self_url() {
|
||||||
|
|||||||
Reference in New Issue
Block a user