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

23 lines
653 B
Markdown
Raw Permalink 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.
2023-08-05 18:56:25 +00:00
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.
2023-04-17 09:11:55 +00:00
2023-08-05 18:56:25 +00:00
Personally, I always add timestamp and extra data in filename to avoid
duplicate.
2023-04-17 09:11:55 +00:00
Example filename: `yyyy/mm/dd/{user_id}-{timestamp}-{extra}.ext`
2023-08-05 18:56:25 +00:00
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`.