Forem

Fortunatus Adegoke
Fortunatus Adegoke

Posted on

The best way to store file paths in the database

In software engineering (API development), I need a professional explanation of how to store file paths in the database when uploading files to the server.

Image description

Although the absolute file path is undoubtedly
a bad strategy, I used to think of two different strategies whenever I'm developing an API system. Relative file paths and URL-based file paths are these two strategies.

The URL-based file path:
https://my-website-domain.com/uploads/filename
The relative file path:
uploads/filename

Which of these methods is better for software engineering in terms of security and flexibility?

I appreciate the clarifications in advance.

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay