r/SpringBoot • u/dotceng • Dec 30 '25
Question How can I handle file uploads in a microservice?
I’m developing an e-commerce microservice project with spring cloud. I want users to can upload files. So I created a service called file service. Actually I’m asking how to design data flow?
For example;
User wants to upload a profile photo. At this point, the main question is whether the upload request should go through the User Service or be sent directly to the File Service. If the request goes directly to the File Service, how should the profile picture information be stored and linked to the user record in the User Service database?
5
u/veryspicypickle Dec 30 '25
Why did you create a “File Service”? What was the driver?
That will answer the question of the data-flow. Or if you even need a “File Service”
2
u/d-k-Brazz Dec 30 '25 edited Dec 30 '25
File service might be needed as a separate blob storage, if you decided to not storing photos into the User table
I suppose this is a concern for separating User and File
Another concern is orchestration - if file service is a separate service then you have two options
The way you go will depend on many other factors which I’m not aware of, but you are
2
u/FooBarBazQux123 Jan 02 '26
Use the single responsibility principle, either all on UserService, or UserService calls File Upload service. Both are fine.
Moreover, if you don’t have multiple departments in your company, 99% of the cases microservices is over engineered
2
u/gaelfr38 Dec 30 '25
User Service to coordinate. File Service should be seen like the User database.
I'm not sure if you mean service as in really separate deployments or just separate classes but the answer is the same.