in src/s3_helper.py [0:0]
def get_object_from_s3(self, s3_url):
"""Return object retrieved from S3 url."""
bucket, path = S3Client.bucket_key_from_s3_uri(s3_url)
try:
payload = self.s3_client.get_object(Bucket=bucket, Key=path).get('Body').read().decode('utf-8')
except ClientError as e:
print(e)
if e.response['Error']['Code'] == "404" or e.response['Error']['Code'] == 'NoSuchKey':
return None
else:
raise ValueError("Failed to retrieve data from {}.".format(s3_url), e)
return payload