Hello everyone, I have a doubt about URLs. Basical...
# server
m
Hello everyone, I have a doubt about URLs. Basically, I am letting users post an image to a specific folder on my server, and I want to send the URLs of the image back to the client, not the file. I'm not sure if this is normally done this way. How do you guys handle this situation? I am trying to display the image by using "$BASE_URL/$PATH"
👀 1
c
For larger app you typically want to store the file in a "service" (like S3, minio, etc) that allows you to use certain features (private links, etc.). If it is a small app (no cluster of webserving nodes) you can put the file on the node's local disk and serve it from there: in that case I'd put Nginx or Caddy in front of my app (using a rev-proxy) and let nginx/caddy serve the static file. The location and name of the file is important in that case. Usually I prefer to have a random file name, with the correct extension. So
my_dirty_meme.gif
get uploaded and you put it in
d/d3/d36/d3652a39f.gif
(the folders are there to ensure the folder contents to not grown too fast, there is a max number of files per folder after which it becomes cumbersome). You can also serve the file from "kotlin" (from the JVM) but the JVM is not optimized for serving files (while nginx/caddy are). If you do not expect much traffic that is fine.
💯 1