NodeJS+Postgres+Sharp
Upload an image to a local server, create thumbnails and save the urls to a postgres database.
- Generate thumbnails via Sharp
Save sampledotenv
as .env
and then add your database user and password.
Customize the setups in the config file '/src/config/config.ts'.
Start your postgres database and run the commands contained in the database.sql file to create the database and two tables.
Compile with Typescript and run command npm start.
Go to http://localhost:8080 with your favorite browser and try the functions:
Upload an image.
The file is saved in the 'build/src/public/uploads' folder.
Thumbnails are created and stored in the 'build/src/public/thumbnails' folder.
Files urls are stored in the database tables.
Get all images: returns the infos of all images uploaded.
Get image by id: returns the infos and the thumbnails urls of a specific image.