コード例 #1
0
def get__download(user):
    try:
        filename = request.args.get('filename')
        assert filename, 'missing filename'
        type_ = request.args.get('type')
        assert type_, 'missing type'
        assert type_ in ('encrypted', 'plaintext', 'signature', 'hashvalue'), 'unknown type'
        return File.download_file(user, filename, type_)
    except AssertionError as e:
        message = e.args[0] if len(e.args) else str(e)
        flash('下载失败!'+message)
        return redirect('/file')
コード例 #2
0
ファイル: home.py プロジェクト: YanhuiJessica/Sfim
def get_download():
    try:
        user = current_user
        fid = request.args.get('fid')
        assert fid, 'missing fid'
        ty = request.args.get('type')
        assert ty, 'missing type'
        assert ty in ('encrypted', 'plaintext', 'signature', 'hashvalue',
                      'publickey'), 'unknown type'
        return File.download_file(user, fid, ty)
    except AssertionError as e:
        message = e.args[0] if len(e.args) else str(e)
        flash('下载失败!' + message)
        return redirect('/home')
コード例 #3
0
def get__download():
    from models import User, File
    try:
        filename = request.args.get('filename')
        assert filename, 'missing filename'
        username = request.args.get('username')
        assert username, 'missing username'
        type_ = request.args.get('type')
        assert type_, 'missing type'
        assert type_ in ('encrypted', 'signature'), 'unknown type'
        user = User.get_by(username=username)
        return File.download_file(user, filename, type_)
    except AssertionError as e:
        message = e.args[0] if len(e.args) else str(e)
        flash('下载失败!' + message)
        return redirect('/shared_file')