This little patch fixes several issues with Antville's metaWeblog.newMediaObject() xml-rpc function. With this patch antville * returns a struct as required by the spec at http://www.xmlrpc.com/metaWeblogNewMediaObject * returns the correct alias / url if you upload two files with the same name. * returns the full url of the object if baseUri is set in app.properties * returns an extra value 'alias' which can be used for further processing by the caller without having to parse the returned url This patch also fixes a typo in blog.files.evalFile. See also http://blogs.23.nu/c0re/stories/234/#235 --md@hudora.de, 2003 --- antville/metaWeblog/metaWeblogAPI.js Thu Jul 24 20:20:58 2003 +++ /usr/local/helma/apps/antville/metaWeblog/metaWeblogAPI.js Thu Jul 24 20:41:21 2003 @@ -232,7 +232,9 @@ * .bits base64, the base64-encoded contents of the file * .name String containing the filename * .type String - * @return String containing the URL of the uploaded file + * @return Object, containing the following properties + * .url String containing the URL of the uploaded file + * .alias Sting containing the alias of the uploaded file */ function newMediaObject(blogid, username, password, fileObject) { var usr = root.blogger.getUser(username,password); @@ -243,13 +245,16 @@ var bytes = Packages.helma.util.Base64.decode(str.toCharArray()); var param = new Object(); param.rawfile = new Packages.helma.util.MimePart(fileObject.name, bytes, fileObject.type); - var result = blog.files.evalFile(param, urs); + var result = blog.files.evalFile(param, usr); if (result.error) throwError ("Error occured while creating new Media Object"); else { - var alias = buildAliasFromFile(param.rawfile); + var alias = param.alias; var file = blog.files.get(alias); - return (getProperty("fileUrl")+blog.alias+"/"+file.name); + var ret = new Object(); + ret.url = getProperty("baseUri")+getProperty("fileUrl")+blog.alias+"/"+file.name; + ret.alias = alias; + return (ret); } }