From 62dc9455754ff41c041b8b614e5c0f09ee2b29bd Mon Sep 17 00:00:00 2001 From: ncgl-syngenta Date: Wed, 2 Feb 2022 15:48:34 -0600 Subject: [PATCH] use io object in kwargs (#99) --- syngenta_digital_dta/s3/adapter.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/syngenta_digital_dta/s3/adapter.py b/syngenta_digital_dta/s3/adapter.py index e5bf9ba..80a2c22 100644 --- a/syngenta_digital_dta/s3/adapter.py +++ b/syngenta_digital_dta/s3/adapter.py @@ -55,9 +55,13 @@ def upload_stream(self, **kwargs): multipart_threshold=kwargs.get('threshold', 10000), max_concurrency=kwargs.get('concurrency', 4) ) - bytesIO = BytesIO(bytes(kwargs['data'])) - with bytesIO as data: - self.client.upload_fileobj(data, self.bucket, kwargs['s3_path'], Config=conf) + + if kwargs.get('io'): + self.client.upload_fileobj(kwargs['io'], self.bucket, kwargs['s3_path'], Config=conf) + else: + with BytesIO(bytes(kwargs['data'])) as data: + self.client.upload_fileobj(data, self.bucket, kwargs['s3_path'], Config=conf) + if kwargs.get('publish', True): super().publish('create', self.__generate_publish_data(**kwargs))