- String mediaId = null;
- MpRequest mpReq = (MpRequest) mp.requestList.get(0);
- String mediaTypeId; //= null;
- MirMedia mediaHandler;
- Database mediaStorage;
-
- // get the content-type from what the client browser
- // sends us. (the "Oreilly method")
- String contentType = mpReq.getContentType();
- String fileName = mpReq.getFilename();
- theLog.printInfo("CONTENT-TYPE FROM BROWSER: " + contentType);
-
- // if the client browser sent us unknown (text/plain is default)
- // or if we got application/octet-stream, it's possible that
- // the browser is in error, better check against the file extension
- if (contentType.equals("text/plain") ||
- contentType.equals("application/octet-stream")) {
- /**
- * Fallback to finding the mime-type through the standard ServletApi
- * ServletContext getMimeType() method.
- *
- * This is a way to get the content-type via the .extension,
- * we could maybe use a magic method as an additional method of
- * figuring out the content-type, by looking at the header (first
- * few bytes) of the file. (like the file(1) command). We could
- * also call the "file" command through Runtime. This is an
- * option that I almost prefer as it is already implemented and
- * exists with an up-to-date map on most modern Unix like systems.
- * I haven't found a really nice implementation of the magic method
- * in pure java yet.
- *
- * The first method we try thought is the "Oreilly method". It
- * relies on the content-type that the client browser sends and
- * that sometimes is application-octet stream with
- * broken/mis-configured browsers.
- *
- * The map file we use for the extensions is the standard web-app
- * deployment descriptor file (web.xml). See Mir's web.xml or see
- * your Servlet containers (most likely Tomcat) documentation.
- * So if you support a new media type you have to make sure that
- * it is in this file -mh
- */
- ServletContext ctx =
- (ServletContext)MirConfig.getPropAsObject("ServletContext");
- contentType = ctx.getMimeType(fileName);
- if (contentType == null)
- contentType = "text/plain"; // rfc1867 says this is the default
- }
- theLog.printInfo("CONTENT TYPE IS: " + contentType);