Skip to content

Commit

Permalink
use io object in kwargs (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncgl-syngenta authored Feb 2, 2022
1 parent 8906031 commit 62dc945
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions syngenta_digital_dta/s3/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit 62dc945

Please sign in to comment.