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))
def generate_random_s3_key(): key = Paste.generate_random_resource_key() return jsonify(key=key)