Exemplo n.º 1
0
def copy():
    fid = get_post_param('file_id', 0, int)
    did = get_post_param('dir_id', 0, int)
    assert fid != 0, 'file_id is required'
    assert did != 0, 'did is required'
    data = file_biz.copy_file(fid, did)
    return make_json_success_response(data)
Exemplo n.º 2
0
def move():
    fid = get_post_param('file_id', 0, int)
    did = get_post_param('dir_id', 0, int)
    assert fid != 0, 'file_id is required'
    assert did != 0, 'did is required'
    file_biz.move_file(fid, did)
    return make_json_success_response({})
Exemplo n.º 3
0
def add_dir():
    dirname = get_post_param('dir_name', '', str)
    dirparent = get_post_param('parent_dir', '', str)
    mode = get_post_param('file_mode', '', str)
    comment = get_post_param('file_comment', '', str)
    assert_param_is_none(dirname, dirparent, mode, comment)
    data = file_biz.add_file(dirname, dirparent, mode, comment, 'd')
    return make_json_success_response(data)
Exemplo n.º 4
0
def login():
    uname = get_post_param('user_name', '', str)
    upwd = get_post_param('user_password', '', str)
    assert_param_is_none(uname, upwd)
    code = user_biz.login_with_name_password(uname, upwd)
    if code != FileManagerErrorCode.ERROR_CODE_OK:
        raise FileManagerException(code)
    return make_json_success_response()
Exemplo n.º 5
0
def add_user():
    uname = get_post_param('user_name', '', str)
    usex = get_post_param('user_sex', '', str)
    uemail = get_post_param('user_email', '', str)
    upwd = get_post_param('user_password', '', str)
    ucomment = get_post_param('user_comment', '', str)
    print locals()
    assert_param_is_none(uname, usex, uemail, upwd, ucomment)
    data = dict(uname=uname,
                usex=usex,
                uemail=uemail,
                upwd=upwd,
                ucomment=ucomment)
    user_biz.add_user(data)
    return make_json_success_response()
Exemplo n.º 6
0
 def _wrapped(*args, **kwargs):
     fid = get_post_param('fid', 0, int)
     assert fid, 'require param: fid'
     user = request.user
     file = file_dal.get_file_by_id(fid)
     if file.uid != user.id:
         raise FileManagerException(ErrorCode.ERROR_CODE_NO_PERMISSION)
     return func(*args, **kwargs)
Exemplo n.º 7
0
def download_file():
    fid = get_post_param('fid', 0, int)
    assert fid, 'fid is null'
    flink = file_biz.get_file_link(fid)
    response = send_from_directory('/home/lxy/Files',
                                   flink,
                                   as_attachment=True)
    response.headers['Access-Control-Allow-Origin'] = 'http://127.0.0.1:8080'
    response.headers['Access-Control-Allow-Credentials'] = "true"
    return response
Exemplo n.º 8
0
def add_file():
    dirname = get_post_param('file_name', '', str)
    dirparent = get_post_param('parent_dir', '', str)
    mode = get_post_param('file_mode', '', str)
    comment = get_post_param('file_comment', '', str)
    file_link = get_post_param('real_name', '', str)
    md5 = get_post_param('md5', '', str)
    assert_param_is_none(dirname, dirparent, mode, comment)
    data = file_biz.add_file(dirname, dirparent, mode, comment, 'r', file_link,
                             md5)
    return make_json_success_response(data)
Exemplo n.º 9
0
def get_dir_files():
    dirname = get_post_param('dir_name', '', str)
    assert_param_is_none(dirname)
    data = file_biz.get_files_by_dir(dirname)
    return make_json_success_response(data)
Exemplo n.º 10
0
def rename():
    fid = get_post_param('fid', -1, int)
    name = get_post_param('new_name', '', str)
    assert fid != -1, 'require param: fid'
    assert name != '', 'require param: new_name'
    file_biz.rename(fid, name)
Exemplo n.º 11
0
def remove():
    fid = get_post_param('fid', 0, int)
    assert fid, 'fid is null'
    file_biz.delete_file(fid)
    return make_json_success_response({})
Exemplo n.º 12
0
def check_file_md5():
    md5 = get_post_param('md5', '', str)
    assert md5, 'md5 is null'
    data = file_biz.get_file_md5(md5)
    return make_json_success_response(data)