display script API on the page
This commit is contained in:
@@ -69,6 +69,29 @@ def get_or_none(key,d,none = None):
|
||||
return none
|
||||
|
||||
|
||||
def get_script_url(public_url, share, end_point, token = "[TOKEN]"):
|
||||
cmd = None
|
||||
doc = None
|
||||
if get_or_none("direct_links", share) and end_point == "download":
|
||||
end_point = "direct"
|
||||
url = "%s/script/%s/%s/%s"%(
|
||||
public_url,
|
||||
end_point,
|
||||
share['name'],
|
||||
token
|
||||
)
|
||||
if end_point in ( "download", "direct"):
|
||||
cmd = 'curl -s %s | bash /dev/stdin [-f]'%( url, )
|
||||
doc = 'Download all files in the share.'
|
||||
if end_point == "client":
|
||||
cmd = 'python <( curl -s %s )'%( url, )
|
||||
doc = 'Console client to download and upload files.'
|
||||
if end_point == "upload_split":
|
||||
cmd = 'curl -s %s | python - [-s split_size_in_Mb] file_to_upload.ext [second.file.ext]'%( url, )
|
||||
doc = 'Upload files to the share.'
|
||||
return {'cmd': cmd, 'doc': doc}
|
||||
|
||||
|
||||
def is_path_safe(path):
|
||||
if path.startswith("."):
|
||||
return False
|
||||
@@ -112,6 +135,7 @@ def iter_folder_files(path, recursive = True):
|
||||
def path2url(path):
|
||||
return pathname2url(path)
|
||||
|
||||
|
||||
def safe_name(s):
|
||||
return safe_string(s, "-_")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user