I have a project with Jhipster ( Spring Boot ) and I need to add as an attachment to an email that generated an image.
The problem is that I do not know where I should locate the image inside the back-end folders or how to make a relative reference from Java so that it works both in development and in production
HttpResponse<String> response =
Unirest.post("https://api.infobip.com/email/1/send")
.header("Authorization", "Basic xxxx=")
.header("Accept", "application/json")
.field("from", "xxx Notifications <notifications-noreply@xxxx.com>", "text/plain")
.field("to", "joseluis.xxx@xxx.com", "text/plain")
.field("replyTo", "xxx@xxx.com", "text/plain")
.field("subject", "Prueba Full", "text/plain")
.field("text", "text prueba full", "text/plain")
.field("html", s, "text/plain")
.field("attachment", new File("/MI_IMAGEN.JPG"))
.field("bulkId", "cusotmBulkId", "text/plain")
.field("intermediateReport", "true", "text/plain")
.field("notifyUrl", "https://www.example.com/email/advanced", "text/plain")
.field("notifyContentType", "application/json", "text/plain")
.field("callbackData", "DLR callback data", "text/plain").asString();
It is this line:
field("attachment", new File("/MI_IMAGEN.JPG"))
I would need to take my image located in a route that I can access in a relative way both in development and in production.