AttachmentManager attmgr = engine.getAttachmentManager();
try
{
Attachment att = new Attachment( engine, blogid, name );
att.setAuthor( username );
attmgr.storeAttachment( att, new ByteArrayInputStream( data ) );
url = engine.getURL( WikiContext.ATTACH, att.getName(), null, true );
}
catch( Exception e )
{
log.error( "Failed to upload attachment", e );
throw new XmlRpcException( 0, "Failed to upload media object: "+e.getMessage() );