Large set of data conatining BASE64 from REST API
I am no expert in Angular, but you could rework your API like this:
- Send to Angular http URL to your API, for example:
http://localhost/api/images/ID/POST_TYPE
- Have an API returning the image (eg:
@GetMapping("/api/images/{id}/{postType}")
) which will do a database query. The image is to be returned as binary content (not base64). (see below)
You may also send cache information, so that the browser does not download again the image.
For the image API, I did not see that you were using the image directly from the file system. You could probably simply map the part after the /app/images
to the path where they are stored.
- Send to Angular the URI: /api/images/uploads/events/WHATEVER
- Read the URI (I'm not expert in Spring MVC either, I don't know if variable can match whole path) after /api/images
- Use this URI to get the actual file
- Use
Files.copy(yourPath, request.getOutputStream())
do perform the actual copy.
Note: for various security reasons
- you should also check - especially if you use path from outside - that the path is effectively where you want it to be.
- you should also check - given images are personal data - the user has really access to it. That's a given with the GRPD.