def _store_csv_data(bucket_name): file_stream = request.files["file"].stream try: if request.content_length > MAX_UPLOAD_SIZE: return _invalid_upload("file too large") try: parse_and_store(db, parse_csv(file_stream), bucket_name, app.logger) return render_template("upload_ok.html") except (ParseError, ValidationError) as e: return _invalid_upload(e.message) finally: file_stream.close()
def _store_csv_data(bucket_name): file_stream = request.files["file"].stream try: if request.content_length > MAX_UPLOAD_SIZE: return _invalid_upload("file too large") try: parse_and_store( db, parse_csv(file_stream), bucket_name, app.logger) return render_template("upload_ok.html") except (ParseError, ValidationError) as e: return _invalid_upload(e.message) finally: file_stream.close()
def post_to_bucket(bucket_name): g.bucket_name = bucket_name if not bucket_is_valid(bucket_name): return jsonify(status="error", message="Bucket name is invalid"), 400 tokens = app.config['TOKENS'] auth_header = request.headers.get('Authorization', None) if not bearer_token_is_valid(tokens, auth_header, bucket_name): statsd.incr("write_api.bad_token", bucket=g.bucket_name) return jsonify(status='error', message='Forbidden'), 403 try: parse_and_store(db, load_json(request.json), bucket_name, app.logger) return jsonify(status='ok') except (ParseError, ValidationError) as e: return jsonify(status="error", message=str(e)), 400
def post_to_bucket(bucket_name): g.bucket_name = bucket_name if not bucket_is_valid(bucket_name): return jsonify(status="error", message="Bucket name is invalid"), 400 tokens = app.config['TOKENS'] auth_header = request.headers.get('Authorization', None) if not bearer_token_is_valid(tokens, auth_header, bucket_name): statsd.incr("write_api.bad_token", bucket=g.bucket_name) return jsonify(status='error', message='Forbidden'), 403 try: parse_and_store( db, load_json(request.json), bucket_name, app.logger) return jsonify(status='ok') except (ParseError, ValidationError) as e: return jsonify(status="error", message=str(e)), 400