Modified to handle paths in s3 keys