Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List tool fix #1226

Merged
merged 9 commits into from
Sep 14, 2023
21 changes: 12 additions & 9 deletions superagi/helper/s3_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,15 @@ def get_download_url_of_resources(self, db_resources_arr):
return response_obj

def list_files_from_s3(self, file_path):
file_path = "resources" + file_path
logger.info(f"Listing files from s3 with prefix: {file_path}")
response = self.s3.list_objects_v2(Bucket=get_config("BUCKET_NAME"), Prefix=file_path)

if 'Contents' in response:
file_list = [obj['Key'] for obj in response['Contents']]
return file_list

raise Exception(f"Error listing files from s3")
try:
file_path = "resources" + file_path
logger.info(f"Listing files from s3 with prefix: {file_path}")
response = self.s3.list_objects_v2(Bucket=get_config("BUCKET_NAME"), Prefix=file_path)
if 'Contents' in response:
logger.info(response['Contents'])
file_list = [obj['Key'] for obj in response['Contents']]
return file_list
else:
raise Exception(f"No contents in S3 response")
except:
raise Exception(f"Error listing files from s3")