예제 #1
0
파일: api.py 프로젝트: NextFloor/paste
def post():
    file = request.files['file']
    key = Paste.generate_random_resource_key()
    Paste.upload_file(key, file)

    paste = Paste(
        key,
        'text',
        request.form.get('expiration', 10080),
        request.form.get('title', file.filename),
        request.form.get('password'),
        True,
    )

    db.session.add(paste)
    db.session.commit()

    return jsonify(code=200,
                   slug=paste.slug,
                   url=url_for('view', slug=paste.slug, _external=True))
예제 #2
0
def generate_random_s3_key():
    key = Paste.generate_random_resource_key()
    return jsonify(key=key)