2

I'm building a system that consists of multiple microservices, databases, a message broker, and a file storage system that primarily stores photos. In my setup, I'm using MinIO as my file storage solution, which is deployed via Docker. The entire infrastructure is behind an API gateway.

I need to allow the frontend to display images by embedding them directly in an tag. To do this, the frontend must receive a URL that points to the file storage. Given that all components are secured behind the API gateway, I'm considering several approaches to organize file storage access:

  1. Proxy via a dedicated endpoint: Create a dedicated API endpoint in one of the microservices that internally fetches the image from the file storage and returns it to the frontend.
  2. Direct link with API gateway proxying: Generate a direct link to the file storage and return it to the frontend, with requests being proxied through the API gateway.
  3. Direct link bypassing the API gateway: Generate a direct link to the file storage and return it to the frontend, bypassing the API gateway altogether.

Which of my options is the best? Are there any best practices or alternative strategies that should be considered?

1 Answer 1

0

Each of these options has advantages and disadvantages, and also implications that aren't necessarily good or bad - they are just stuff you have to deal with. There is no option which is "best" in an absolute sense - options only have varying levels of suitability for a given problem.

Check to see if you have any guidance (e.g. architecture, internal standards or policies) that helps give direction.

If your architecture does not provide an answer on this then keep in mind that when you do make a decision you should record it as a pattern (noting when the pattern is applicable, when and why yo sue it, etc).

try and identify what "good" looks like, by drawing up a list of things that you think are important for any solution to be "good" (successful). Then score each option against that list. Things to consider when drawing up your list:

  • (In no particular order): performance, security, maintainability, testability.

  • Specific scenarios e.g. what happens if you want (or are forced to) to change the backend file storage technology? What happens if the API GW changes? What sorts of client will be requesting the files, and what happens if a new client type is needed?

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.