def newMediaObject(self, blogid, username, password, struct):
     """See IMetaWeblogAPI
     """
     # These first three are required to be present by the spec.
     name = struct['name']
     mimetype = struct['type']
     bits = struct['bits']
     # We support the presence of a 'title' element, just in case the client
     # sends it.
     title = struct.get('title', '')
     weblog = IUIDManager(self.context).getByUID(blogid)
     weblog = IWeblog(weblog)
     obj = weblog.addFile(bits.data, mimetype, name, title)
     # XXX This next line should almost certainly adapt to IAbsoluteURL,
     #     rather than assume that the returned object has an absolute_url
     #     method!
     if getattr(obj, 'absolute_url', None):
         url = obj.absolute_url()
     else:
         url = obj.context.absolute_url()
     return {'url': url}