-- Disable triggers
UPDATE "pg_class" SET "reltriggers" = 0 WHERE "relname" = 'media_type';
-INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (2,'unknown','application/octet-stream','--','UploadedMedia',NULL);
+INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (2,'unknown','application/octet-stream','Generic','UploadedMedia',NULL);
INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (3,'jpg','image/gif','ImagesGif','Images',NULL);
INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (4,'mp3','audio/mp3','Audio','UploadedMedia',NULL);
INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (5,'jpg','image/jpeg','ImagesJpeg','Images',NULL);
INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (7,'mpg','video/mpeg','Video','UploadedMedia',NULL);
INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (8,'mov','video/quicktime','Video','UploadedMedia',NULL);
INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (9,'avi','video/x-msvideo','Video','UploadedMedia',NULL);
-
-
-
INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (10,'ra','audio/vnd.rn-realaudio','RealAudio','UploadedMedia',NULL);
INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (11,'rm','video/vnd.rn-realvideo','RealVideo','UploadedMedia',NULL);
+INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (12,'ra','audio/x-pn-realaudio','RealAudio','UploadedMedia',NULL);
+INSERT INTO "media_type" ("id","name","mime_type","classname","tablename","dcname") VALUES (13,'mp3','audio/x-mp3','Audio','UploadedMedia',NULL);
-- Enable triggers
MpRequest mpReq = (MpRequest)it.next();
String fileName = mpReq.getFilename();
- //This is just a temporary way to get the content-type via
- //the .extension , we need to use a magic method, by looking
- //at the header (first few bytes) of the file.
- //the Oreilly method sucks cause it relies on the
- //content-type the client browser sends and that's
- //too often application-octet stream. -mh
- String contentType = FileUtil.guessContentTypeFromName(fileName);
+ //get the content-type from what the client browser
+ //sends us. (the "Oreilly method")
+ String contentType = mpReq.getContentType();
+
+ theLog.printError("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")) {
+ /**
+ * This is just a temporary way to get the content-type via
+ * the .extension , we could maybe use a magic method, by looking
+ * at the header (first few bytes) of the file. (like the file(1)
+ * command).
+ * The Oreilly method 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 should be Mir/content-types.properties, it's the
+ * default Sun Java file with some additional entries that it did
+ * not have. So if you support a new media type you have to make
+ * sure that it is in this file -mh
+ */
+ contentType = FileUtil.guessContentTypeFromName(fileName);
+ if (contentType==null)
+ contentType = "text/plain"; // rfc1867 says this is the default
+ }
HashMap mediaValues = new HashMap();
theLog.printError("CONTENT TYPE IS: "+contentType);
- //The map file should be Mir/content-types.properties, it's the
- //default Sun Java file+ some entries that it did not have.
- //so if you support a new media type you have to make sure that
- //it is in this file -mh
- if ((contentType==null) || (contentType=="application/octet-stream")) {
+ if (contentType.equals("text/plain") ||
+ contentType.equals("application/octet-stream")) {
throw new ServletModuleException("ModuleException: One or more files of unrecognized types");
}