posts-go/posts/2023-04-17-naming.md

20 lines
653 B
Markdown
Raw Normal View History

2023-04-17 09:11:55 +00:00
# Naming things
## Filename in storage (S3, ...)
Always have year, month, day in filename to easily sort it out.
If file is uploaded by user, add `user_id` in filename, or some other unique identifier depends on your business in which you require to upload.
Personally, I always add timestamp and extra data in filename to avoid duplicate.
Example filename: `yyyy/mm/dd/{user_id}-{timestamp}-{extra}.ext`
Be careful with `/`, too much nested folder is no good for backup (as they say, idk if true or not, but less folder mean less complicated to me).
2023-06-15 19:21:12 +00:00
## Time variable
Add time postfix to make sense.
Instead of `create_at`, use `create_at_ms`.