in iopath/common/s3.py [0:0]
def s3_close_and_upload(self, client, bucket, s3_path, transfer_config):
# Seek to start, for use by upload_fileobj.
self.seek(0)
# Reinstall the proper close.
self.close = self._close
# upload_fileobj needs bytes
# NOTE: This is undesirable.
if isinstance(self, io.StringIO):
self = io.BytesIO(self.getvalue().encode("utf-8"))
# Upload
try:
client.upload_fileobj(
self,
bucket,
s3_path,
Config=transfer_config,
)
except botocore.exceptions.ClientError as e:
raise OSError(f"Error in file upload - {e}" f"{type(e).__name__}: {e}") from e