[Python] Sub Folders of S3 bucket - Bucket name must match the regex "^[a-zA-Z0-9.\-_]

Discussão em 'Python' iniciado por Stack, Março 21, 2025.

  1. Stack

    Stack Membro Participativo

    I have below code to get the list of objects in the bucket, but it does not work for the sub folders of the S3.

    import boto3

    bucket_from = "BucketSource"
    s3 = boto3.resource('s3')
    src = s3.Bucket(bucket_from)

    for archive in src.objects.all():
    print(archive.key)


    While using sub folders, FirstLevelS3/SecondLevelS3/BucketSource, this is the error:

    Bucket name must match the regex "^[a-zA-Z0-9.\-_]

    Continue reading...

Compartilhe esta Página