public IDictionary NewMediaObject(string blogid, string username, string password, NewMediaObjectArgs args)
        {
            CheckBlogId(blogid);
            CheckCredentials(username, password);

            string dir  = _blogConfig.UploadDir;
            string path = _blogConfig.UploadPath;

            if (dir == null || path == null)
            {
                throw new XmlRpcServerException(403, "This server is not configured for newMediaObject support.");
            }

            if (path != null && !path.EndsWith("/"))
            {
                path += "/";
            }

            if (!Directory.Exists(dir))
            {
                throw new XmlRpcServerException(500, "The newMediaObject upload directory does not exist");
            }

            string fileExt = Util.GetExtensionForContentType(args.Type);

            if (fileExt == null)
            {
                throw new XmlRpcServerException(403, "Couldn't determine an extension for the given content type");
            }
            string fileName     = Guid.NewGuid().ToString("d") + fileExt;
            string fullFileName = Path.Combine(dir, fileName);

            using (Stream s = new FileStream(fullFileName, FileMode.CreateNew, FileAccess.Write, FileShare.Write, 8192))
            {
                StreamHelper.Transfer(new MemoryStream(args.Bits), s);
            }

            return(Util.MakeDictionary("url", path + HttpUtility.UrlPathEncode(fileName)));
        }
		public IDictionary NewMediaObject(string blogid, string username, string password, NewMediaObjectArgs args)
		{
			CheckBlogId(blogid);
			CheckCredentials(username, password);
			
			string dir = _blogConfig.UploadDir;
			string path = _blogConfig.UploadPath;
			
			if (dir == null || path == null)
				throw new XmlRpcServerException(403, "This server is not configured for newMediaObject support.");
			
			if (path != null && !path.EndsWith("/"))
				path += "/";
			
			if (!Directory.Exists(dir))
				throw new XmlRpcServerException(500, "The newMediaObject upload directory does not exist");

			string fileExt = Util.GetExtensionForContentType(args.Type);
			if (fileExt == null)
				throw new XmlRpcServerException(403, "Couldn't determine an extension for the given content type");
			string fileName = Guid.NewGuid().ToString("d") + fileExt;
			string fullFileName = Path.Combine(dir, fileName);
			using (Stream s = new FileStream(fullFileName, FileMode.CreateNew, FileAccess.Write, FileShare.Write, 8192))
			{
				StreamHelper.Transfer(new MemoryStream(args.Bits), s);
			}
			
			return Util.MakeDictionary("url", path + HttpUtility.UrlPathEncode(fileName));
		}