show a single filename
This commit is contained in:
@@ -14,7 +14,7 @@ from utils.utils import *
|
|||||||
from utils.crypt import *
|
from utils.crypt import *
|
||||||
|
|
||||||
|
|
||||||
__FLEES_VERSION__ = "20180310.0"
|
__FLEES_VERSION__ = "20180416.0"
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.from_object(__name__)
|
app.config.from_object(__name__)
|
||||||
# Read config from json !
|
# Read config from json !
|
||||||
|
|||||||
@@ -357,14 +357,15 @@ def print_rest_api(shares, config, opts):
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if opts.type == "login":
|
if opts.type == "login":
|
||||||
print_rest_api_login(config,share,token)
|
print_rest_api_login(config,share,token)
|
||||||
elif opts.type == "upload":
|
elif opts.type == "upload":
|
||||||
print_rest_api_upload(config,share,token)
|
print_rest_api_upload(config,share,token)
|
||||||
elif opts.type == "download":
|
elif opts.type == "download":
|
||||||
print_rest_api_download(config, share, token)
|
print_rest_api_download(config, share, token, opts.filename)
|
||||||
elif opts.type == "direct":
|
elif opts.type == "direct":
|
||||||
print_rest_api_direct(config, share, token)
|
print_rest_api_direct(config, share, token, opts.filename)
|
||||||
elif opts.type == "zip":
|
elif opts.type == "zip":
|
||||||
print_rest_api_zip(config, share, token)
|
print_rest_api_zip(config, share, token)
|
||||||
|
|
||||||
@@ -410,7 +411,7 @@ def print_rest_api_upload(config, share, token):
|
|||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
def print_rest_api_download(config, share, token):
|
def print_rest_api_download(config, share, token, show_filename):
|
||||||
print("Links to download files:")
|
print("Links to download files:")
|
||||||
share_path = os.path.join(
|
share_path = os.path.join(
|
||||||
config['__root_path__'],
|
config['__root_path__'],
|
||||||
@@ -421,6 +422,9 @@ def print_rest_api_download(config, share, token):
|
|||||||
print("no files")
|
print("no files")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
for filename in iter_folder_files(share_path):
|
for filename in iter_folder_files(share_path):
|
||||||
|
if show_filename:
|
||||||
|
if filename != show_filename:
|
||||||
|
continue
|
||||||
print("%s/download/%s/%s/%s"%(
|
print("%s/download/%s/%s/%s"%(
|
||||||
config['public_url'],
|
config['public_url'],
|
||||||
share['name'],
|
share['name'],
|
||||||
@@ -435,7 +439,7 @@ def print_rest_api_download(config, share, token):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def print_rest_api_direct(config, share, token):
|
def print_rest_api_direct(config, share, token, show_filename):
|
||||||
if 'direct_links' not in share or not share['direct_links']:
|
if 'direct_links' not in share or not share['direct_links']:
|
||||||
print("Direct downloading not allowed in this share")
|
print("Direct downloading not allowed in this share")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
@@ -449,6 +453,9 @@ def print_rest_api_direct(config, share, token):
|
|||||||
print("no files")
|
print("no files")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
for filename in iter_folder_files(share_path):
|
for filename in iter_folder_files(share_path):
|
||||||
|
if show_filename:
|
||||||
|
if filename != show_filename:
|
||||||
|
continue
|
||||||
print("%s/direct/%s/%s/%s"%(
|
print("%s/direct/%s/%s/%s"%(
|
||||||
config['public_url'],
|
config['public_url'],
|
||||||
share['name'],
|
share['name'],
|
||||||
@@ -598,6 +605,10 @@ def parse_options():
|
|||||||
parser_rest.add_argument(dest="type", help = "Type of command",
|
parser_rest.add_argument(dest="type", help = "Type of command",
|
||||||
choices = ['list','login','upload','download','direct','zip']
|
choices = ['list','login','upload','download','direct','zip']
|
||||||
)
|
)
|
||||||
|
parser_rest.add_argument(dest="filename", help = "File name for download/direct queries",
|
||||||
|
nargs = '?',
|
||||||
|
default = None
|
||||||
|
)
|
||||||
parser_rest.add_argument('-t','--token', action="store", dest="token", default = None,
|
parser_rest.add_argument('-t','--token', action="store", dest="token", default = None,
|
||||||
help= "If share has multiple tokens, select one to print REST API for."
|
help= "If share has multiple tokens, select one to print REST API for."
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user