Amazon S3 has no such thing as folders. This is a flat file system. The closer you can get to the folders, so add prefixes, as you said: 5/D/image.jpg to your file names. In this case, 5 is a prefix, and 5/D also a prefix. On the other hand, your delimiter may be / .
Although several S3 tools will show you things as if they were contained inside folders, this concept does not exist on S3. Check out this and this related threads.
You can definitely use the template you suggested, and I don't think you will incur any performance penalties by doing this.
source share