web server file storage
is it a bad practice to store large file >10mb in a database?
when needing to store user uploaded files or any sort of static files (at least bigger than an svg), the recommended solution is to store the file in a file system (host or cloud) and in the database store path/URI to file.
a solution to this is using a 3rd party service to host this files:
- S3
- uploadthing
- cloudinary
These have more benefits like serving through big CDNs and __
js projects
For static assets (images/videos) in Nextjs projects:
- storing in
/public- smaller bundle size, won't be included in the final app bundle and instead will be hosted in a CDN when using services like Vercel
/src/assetsor/src/...- will be included in final app bundle. increasing it's size and loading time.
When you import an asset (even from the /public dir) it's processed by Next at built time. It is optimized, given a hash and contains metadata. This asset is now included in the app bundle.
I think I wouldn't want a 30kb excel file in the app bundle. Webpack doesn't bundle >8kb files