Example #1
0
def download(filehash):
    paste_file = PasteFile.get_by_filehash(filehash)
    return send_file(open(paste_file.path, 'rb'),
                     mimetype='application/octet-stream',
                     cache_timeout=ONE_MONTH,
                     as_attachment=True,
                     attachment_filename=PasteFile.filename.encode('utf-8'))
Example #2
0
def rsize(img_hash):
    w = request.args['w']
    h = request.args['h']

    old_paste = PasteFile.get_by_filehash(img_hash)
    new_paste = PasteFile.rsize(old_paste, w, h)

    return new_paste.url_i
Example #3
0
def download(filehash):
    paste_file = PasteFile.get_by_filehash(filehash)

    return send_file(open(paste_file.path, 'rb'),
                     mimetype='application/octet-stream',
                     cache_timeout=ONE_MONTH,
                     as_attachment=True,
                     attachment_filename=paste_file.filename.encode('utf-8'))
Example #4
0
def rsize(img_hash):
    w = request.args['w']
    h = request.args['h']

    old_paste = PasteFile.get_by_filehash(img_hash)
    new_paste = PasteFile.rsize(old_paste, w, h)

    return new_paste.url_i
Example #5
0
def rsize(img_hash):
    w = request.args['w']
    h = request.args['h']

    # 其中get_by_filehash方法就是从数据库中找到匹配filehash的条目
    old_paste = PasteFile.get_by_filehash(img_hash)
    new_paste = PasteFile.rsize(old_paste, w, h)
    # url_i属性获取的是源文件的地址
    return new_paste.url_i
Example #6
0
def preview(filehash):
    paste_file = PasteFile.get_by_filehash(filehash)
    if not paste_file:
        filepath = get_file_path(filehash)
        if not (os.path.exists(filepath) and (not os.path.islink(filepath))):
            return abort(404)
        paste_file = PasteFile.create_by_old_paste(filehash)
        db.session.add(paste_file)
        db.session.commit()
    return render_template('success.html', p=paste_file)
Example #7
0
def preview(filehash):
    paste_file = PasteFile.get_by_filehash(filehash)

    if not paste_file:
        filepath = get_file_path(filehash)
        if not(os.path.exists(filepath) and (not os.path.islink(filepath))):
            return abort(404)

        paste_file = PasteFile.create_by_old_paste(filehash)
        paste_file.save()

    return render_template('success.html', p=paste_file)