I am writing a Spring Rest service which will have to return a file with extension .oft (ex Like Sample.oft)
This oft file will be opened in Microsoft outlook application. But I don't find any specific MimeType to set in ResponseEntity object.
If I need create custom mime type, how do I implement it?
Else is there any other file extension I can use? (.eml extension does not work either)
Microsoft Outlook Email Template (.oft
) has basically the same format as .msg
. It's proven that Outlook Emails (.msg
) are associated properly by following Mime-Type:
application/vnd.ms-outlook
So I would suggest to use this Mime-Type, because will ensure:
See Baeldung's tutorial Download an Image or a File with Spring MVC:
@GetMapping(
value = "/download-oft",
produces = "application/vnd.ms-outlook"
)
public @ResponseBody byte[] getFile() throws IOException {
InputStream in = getClass()
.getResourceAsStream("/path/to/your/email_template.oft");
return IOUtils.toByteArray(in);
}
Note: Above implementation uses Apache's IOUtils.