I'm still in the process of migrating my tomcat 8.5.11 to 10.1.13. So for so
good with the help of Christopher Schultz and others on this list. Thanks.
My next challenge is migrating the 8.5 apps using org.apache.commons.fileupload
to jakarta.servlet.annotation.MultipartConfig.
I've got it partially working. One problem is determining the content type of
the uploaded file. In my code I have:
Part fileUpload = request.getPart("newFile");
if (fileUpload != null)
{
fileUpload.write("boogaPhoto");
Path filePath = Paths.get("/tmp/boogaPhoto");
contentType = Files.probeContentType(filePath);
:
The problem is that the content type comes back null. But ...
$ file /tmp/boogaPhoto
/tmp/boogaPhoto: JPEG image data, JFIF standard 1.02, resolution (DPI), density
72x72, segment length 16, baseline, precision 8, 186x253, components 3
The old:
contentType = (fileItem).getContentType();
if (contentType.compareToIgnoreCase("image/jpeg") == 0) suffix = ".jpg";
else if (contentType.compareToIgnoreCase("image/gif") == 0) suffix = ".gif";
else if (contentType.compareToIgnoreCase("image/png") == 0) suffix = ".png";
did return a usable content type.
How do I do this with "new" java.nio.file classes ... or is there a better way?
Thanks --Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]