In GCS I have bucket XYZ, under that I have folder JM, under that I have files. For example:
XYZ/JM/file1.tar.gz,XYZ/JM/file2.tar.gz,XYZ/JM/file3.tar.gz,XYZ/JM/file4.tar.gz etc.
Using the code below I am able to list the files but its displaying the full path like:
JM/file1.tar.gz,JM/file2.tar.gz,JM/file3.tar.gz
Code:
from google.cloud import storage
storage_client = storage.Client.from_service_account_json()
BucketName="XYZ"
bucket=storage_client.get_bucket(BucketName)
filename=list(bucket.list_blobs(prefix="jm/"))
for name in filename:
print(name.name)
Query: I want to list the files under folder JM. I don't want to display JM in the list, just display file ex: file1.tar.gz,file2.tar.gz