forloop for upload script
This commit is contained in:
18
code/app.py
18
code/app.py
@@ -205,16 +205,22 @@ def script_upload(name = None, password = None):
|
||||
if not get_or_none(share,'upload') == True:
|
||||
return "Upload not allowed",400
|
||||
return """#!/bin/bash
|
||||
file_name="$1"
|
||||
base_name=$( basename "$1" )
|
||||
test -f "$file_name" || {
|
||||
echo "Add file as argument"
|
||||
exit 1
|
||||
test -f "$1" || {
|
||||
echo "Add files to upload as argument"
|
||||
exit 1
|
||||
}
|
||||
CAT=$( which cat )
|
||||
which pv &> /dev/null && CAT=$( which pv )
|
||||
|
||||
$CAT "$file_name" | curl -F "file=@-;filename=${base_name}" %supload/%s/%s
|
||||
for file_name in "$@"; do
|
||||
base_name=$( basename "$file_name" )
|
||||
test -f "$file_name" || {
|
||||
echo "'$file_name' not a file"
|
||||
continue
|
||||
}
|
||||
|
||||
$CAT "$file_name" | curl -F "file=@-;filename=${base_name}" %supload/%s/%s
|
||||
done
|
||||
"""%(
|
||||
request.url_root,
|
||||
name,
|
||||
|
||||
Reference in New Issue
Block a user