DEV Community

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)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more