We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fd187a3 commit c02591aCopy full SHA for c02591a
podaac/hitide_backfill_tool/s3_reader.py
@@ -45,3 +45,20 @@ def read_file_from_s3(self, s3_path):
45
return response["Body"].read().decode("ISO-8859-1")
46
except ClientError as exc:
47
raise Exception(f"S3Reader could not read file at {s3_path}.") from exc
48
+
49
+ def list_s3_keys(self, s3_path):
50
+ """
51
+ List all keys in a s3 bucket from input s3_path
52
53
+ :return: List of file keys in the specified directory.
54
55
56
+ bucket_name, prefix = self.extract_bucket_and_file(s3_path)
57
58
+ s3_client = boto3.client("s3")
59
+ response = s3_client.list_objects_v2(Bucket=bucket_name, Prefix=prefix)
60
61
+ if "Contents" in response:
62
+ return [obj["Key"] for obj in response["Contents"]]
63
+ else:
64
+ return []
0 commit comments