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)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

πŸ‘₯ Ideal for solo developers, teams, and cross-company projects

Learn more

πŸ‘‹ Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay