Skip to content

Commit

Permalink
Merge pull request #1226 from TransformerOptimus/list_tool_fix
Browse files Browse the repository at this point in the history
List tool fix
  • Loading branch information
Tarraann authored Sep 14, 2023
2 parents 6b86162 + d8c57f7 commit e830bd7
Showing 1 changed file with 12 additions and 9 deletions.
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")

0 comments on commit e830bd7

Please sign in to comment.