I have the following method in Python:
def read_file(self, bucket, table_name, file_name, format="csv"):
data = None
read_from_path = f"s3://{bucket}/{table_name}/{file_name}"
try:
fs = s3fs.S3FileSystem(
key=self.dwh_s3_client_key, secret=self.dwh_s3_client_secret
)
with fs.open(read_from_path, "r") as f:
data = f.read()
return data
except Exception as e:
raise Exception(
f"Failed to read file {read_from_path} from S3 due to this error:\n`{str(e)}`"
)
The problem is that I get an Access Denied
error, but I'm able to read the files in the bucket, it fails only when attempting to read the content of one of the files.
Is what I am doing the right way to read a file from s3 using s3fs
?