Skip to content

Commit

Permalink
list tool fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rounak610 committed Sep 12, 2023
1 parent 7e5e305 commit 99d0271
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions superagi/helper/s3_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,13 @@ 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
except:
raise Exception(f"Error listing files from s3")

0 comments on commit 99d0271

Please sign in to comment.