From 2fb1df34c9ed76c938c534a82274e88fa8d7a9ad Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Fri, 12 Aug 2016 21:23:25 -0400 Subject: [PATCH] recorder: add upload/streaming support with put_record=stream where the content being uploaded is already in WARC record form --- recorder/recorderapp.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/recorder/recorderapp.py b/recorder/recorderapp.py index 6b9a813e..eeded251 100644 --- a/recorder/recorderapp.py +++ b/recorder/recorderapp.py @@ -94,6 +94,15 @@ class RecorderApp(object): def _put_record(self, request_uri, input_buff, record_type, headers, params, start_response): + if record_type == 'stream': + if self.writer.write_stream_to_file(params, input_buff): + msg = {'success': 'true'} + else: + msg = {'error_message': 'upload_error'} + + return self.send_message(msg, '200 OK', + start_response) + req_stream = ReqWrapper(input_buff, headers) while True: @@ -123,6 +132,13 @@ class RecorderApp(object): return params def __call__(self, environ, start_response): + try: + return self.handle_call(environ, start_response) + except: + import traceback + traceback.print_exc() + + def handle_call(self, environ, start_response): input_req = DirectWSGIInputRequest(environ) params = self._get_params(environ)