Ejemplo n.º 1
0
def download(file_hash):
    paste_file = File.get_by_filehash(filehash=file_hash)
    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'))
Ejemplo n.º 2
0
def rsize(img_hash):
    w = request.args.get('w')
    h = request.args.get('h')

    old_paste = File.get_by_filehash(img_hash)
    new_paste = File.rsize(old_paste, w, h)
    return new_paste.url_i
Ejemplo n.º 3
0
def preview(file_hash):
    paste_file = File.get_by_filehash(file_hash)
    if not paste_file:
        path = get_file_path(file_hash)
        if not os.path.exists(path) and (not os.path.islink(path)):
            return abort(404)

        paste_file = File.create_by_old_paste(file_hash)
        db.session.add(paste_file)
        db.session.commit()

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