[Phoenix-commits] rev 19188 -
public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content
andi at wyona.com
andi at wyona.com
Fri Oct 6 19:28:00 CEST 2006
Author: andi
Date: 2006-10-06 19:27:59 +0200 (Fri, 06 Oct 2006)
New Revision: 19188
Modified:
public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/widget.js
Log:
MIME media type detection.
Modified: public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/widget.js
===================================================================
--- public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/widget.js 2006-10-06 17:06:53 UTC (rev 19187)
+++ public/yulup/src/trunk/yulup/prototypes/prototype1/src/chrome/content/widget.js 2006-10-06 17:27:59 UTC (rev 19188)
@@ -467,6 +467,9 @@
showResourceUploadDialog: function(aURI) {
var returnObject = null;
+ var mimeService = null;
+ var sourceFile = null;
+ var mimeType = null;
/* DEBUG */ dump("Yulup:widet.js:ResourceUploadDialogHandler.showResourceUploadDialog() invoked\n");
@@ -483,8 +486,19 @@
/* DEBUG */ dump("Yulup:widet.js:ResourceUploadDialogHandler.uploadResource: implement file upload\n");
- NetworkService.httpRequestUploadFile(returnObject.collectionURI.spec, PersistenceService.getFileDescriptor(returnObject.resourceURI), null, null, null, null, null, true);
+ // figure out MIME type
+ mimeService = Components.classes["@mozilla.org/mime;1"].getService(Components.interfaces.nsIMIMEService);
+ sourceFile = PersistenceService.getFileDescriptor(returnObject.resourceURI);
+ try {
+ mimeType = mimeService.getTypeFromFile(sourceFile);
+ } catch (exception) {
+ // could not figure out MIME type, fall back to generic octet-stream
+ mimeType = "application/octet-stream";
+ }
+
+ NetworkService.httpRequestUploadFile(returnObject.collectionURI.spec, sourceFile, null, mimeType, null, null, null, true);
+
/*
var dialog = Components.classes["@mozilla.org/progressdialog;1"].createInstance(Components.interfaces.nsIProgressDialog);
var persist = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(Components.interfaces.nsIWebBrowserPersist);
More information about the Phoenix-commits
mailing list