def ShareId(self, path): from diskcloud.libs.share import get_sid from diskcloud.libs.response import gen_json_res result = valid_url_path(path) if isinstance(result, dict): result = get_sid(result['username'], result['path'], result['name']) if isinstance(result, dict): return gen_json_res(result) return result
def StarInfo(self, path): from diskcloud.libs.file import get_star_info from diskcloud.libs.response import gen_json_res result = valid_url_path(path, True) if isinstance(result, dict): if result['path'] == '.' and result['name'] == '.': json_obj = get_star_info(result['username']) return gen_json_res(json_obj) else: return gen_error_res('无效的URL', 400) return result
def Info(self, path): from diskcloud.libs.file import get_folder_content from diskcloud.libs.response import gen_json_res result = valid_url_path(path, True) if isinstance(result, dict): if result['is_file']: pass else: json_obj = get_folder_content(result['username'], result['path'], result['name']) return gen_json_res(json_obj) return result
def SearchInfo(self, path): from diskcloud.libs.file import get_search_info from diskcloud.libs.response import gen_json_res search_text = request.args.get('search_text', None) if search_text is None: return gen_error_res("无效的请求参数", 400) result = valid_url_path(path, True) if isinstance(result, dict): if result['path'] == '.' and result['name'] == '.': json_obj = get_search_info(result['username'], search_text) return gen_json_res(json_obj) else: return gen_error_res('无效的URL', 400) return result
def Share(self, path): from diskcloud.libs.share import generate_id from diskcloud.libs.response import gen_json_res result = valid_url_path(path) if isinstance(result, dict): # check id_life id_life = request.args.get('life') if id_life is None: return gen_error_res('无效的时间参数', 400) try: id_life = int(id_life) except ValueError: return gen_error_res('无效的时间参数', 400) if not 0 <= id_life <= 24: return gen_error_res('无效的时间参数', 400) # generate share id result = generate_id(result['username'], result['path'], result['name'], id_life) if result['succeed']: return gen_json_res({'sid': result['sid']}) return gen_error_res(result['reason'], 500) return result