I am having challenges architecting my S3 bucket structure.
My Application
I have several types (roles) of users and each user has different types of PDF documents that will be uploaded to S3. The user will see each document in their dashboard and should be able to view the PDF from the application (ideally by opening in a new tab instead of downloading it). Below is an example:
User Roles
User Documents (for role_a)
User Documents (for role_b)
Each user can have zero or more documents.
My questions:
There is no such thing really as a nested structure. Al files in s3 are stored as a bucket and key where the key is the structure the part you think is directories. You can confirm this by storing one document in a bucket say /foo/bar/doc.pdf. then delete that file and look at the structure in s3. Foo and bar will be gone.
So you could do things in many ways, one would be:
Bucket: mybucket
Key: /role_a/document_type_a/0888a5ce.pdf
The simplest structure would be a totally flat storage structure:
You could choose to prefix each object with a user identifier, which is useful for debugging or trying to reconstruct content in case of a database failure, but there is no particular performance benefit if you are correctly referencing the database for a list of user files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With