Community Server newMediaObject

I wanted to see if the newMediaObject module, offered by the Community Server team, had benefits over my current implementation. Although I still have to figure out why, the implementation we had running kept creating copies of the media objects when re-publishing something. After updating, this doesn’t happen anymore, something that can save me some megabytes.

I did make a change though. We’re using George J. Capnias’ FreeTextBox wrapper and it uses the fullname as storage location. That’s why I’ve changed inside the original version. You can download it here.

However, if you’d like to make the changes yourself or change it to something completely else, you can do it yourself. Create a local copy of your community and place the .ashx file inside the /blogs/ directory and open it with Visual Studio and set a breakpoint at the first line in the MetaWeblog2.MediaObjectInfo method. Then from the VS2005 menu choose Debug -> Attach to process… Choose the aspnet_wp.exe process. Open Windows Live Writer, create a new post, insert an image and publish it. Visual Studio 2005 should pick up the request and start debugging.

The code I changed is merely the lines below the commented out lines.

if (mediaObject.bits != null && !Globals.IsNullorEmpty(mediaObject.name))
{
  //AddFile(weblog.ApplicationKey, new MemoryStream(mediaObject.bits), mediaObject.bits.Length, mediaObject.name);
  AddFile(username, new MemoryStream(mediaObject.bits), mediaObject.bits.Length, mediaObject.name);
 
  MediaObjectInfo info = new MediaObjectInfo();
  //info.url = Globals.FullPath(FileStorageUrl(weblog.ApplicationKey, mediaObject.name));
  info.url = Globals.FullPath(FileStorageUrl(username, mediaObject.name));
  return info;
}

You may also like...

Click on a tab to select how you'd like to leave your comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.