Reputation: 14436
I have an S3 prefix. I want to find out, if it's a file or a whole folder. How do I do this with boto3?
Upvotes: 2
Views: 1921
Reputation: 1213
As was stated in a comment, there is no notion of directories in S3. You can find out if the object is a file by attempting to retrieve it, but in order to determine if it is a "directory", you would have to list all the objects in the bucket and determine if the provided value is a prefix to any of them. This may not be feasible for you depending on how many items exist (or can exist) in the bucket.
Upvotes: 1