Lubo Blagoev's Blog

My thoughts on software and technology

Attach File Plugin for Windows Live Writer


[Update:] v.1.2 Fixed changing a file attachment to a new file with the same filename

[Update:] v.1.1 Added a tooltip on long filenames

I wrote a simple plugin for Windows Live Writer. Sidebar support

Attach File Plugin allows you

  • To attach a file into your blog post.
  • Modify attachment properties from WLW Sidebar
  • Include Google tracking code for the attached file.
  • You can upload the files using FTP if you set WLW to use ftp for images.

One important fact Windows Live Writer handles post files very bad. The API and implementation is awful. Test it for yourself . Add a picture to your post. Note in source the href of that picture. Change a property of that picture. (Size, Borders, Wrappings, Margins). Note the href again. Did it change? Yes it did. What happened is that WLW copy the picture every time you change something. You end up with a file name “Me and my girl at the beach[0][1][2][0][9].jpg”. More over they do this on the UI thread. Yes If I want to insert a 25MB picture it gets copied over and over again on the UI thread. It takes 7 seconds right now to get to a blinking cursor from a selected image on my Dual Core 2,4GHz, 4GB RAM machine. I guess they do some serialization of the post at that time. I noticed they call SmartContentSource.GeneratePublishHtml() many times.

It gets worse as you dig in. Plug-ins are able to kill the hosting process by just accessing publishingContext properties in GeneratePublishHtml method.

You can’t post files with spaces in the name and more than certain limit on the filename length. You save a draft post, restart WLW open the draft and voila you have a href to a file “ConcurencyandParallelProgra.txt” instead of the original “Concurency and Parallel Programming.txt”

The docs for Distributing Plugins are wrong. Do not put your registry settings under “HKEY_CURRENT_USER\SOFTWARE\Windows Live\Writer\PluginAssemblies”, instead use “HKEY_CURRENT_USER\SOFTWARE\Windows Live Writer\PluginAssemblies”. They enumerate both paths but load dlls only from the later.

 

That’s the reason I wrote this plugin myself. None of the plug-ins that add files to your post handles these issues. Not even the default Microsoft plug-ins. (Insert Picture) I hope i managed to work around these problems.

Lastly Google PageView option allows you to track downloads of the attached file. Refer to this page for more.

Example: If you set the PageView to “my file” the generated html will be

<a href="http://www.example.com/files/map.pdf" onClick="javascript: pageTracker._trackPageview('my file'); ">

 

Here are the installation packages and source code

 

P.S. I will post the plugin to Windows Live Writer Gallery later since the site is not working right now. (ARGHHHHHH!!!)

Lubo.

Currently rated 3.0 by 2 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

March 8, 2009 17:02 by lubo
Tags: , ,
Categories:

Comments

January 4. 2010 10:03 by shailesh

Hi lubo,
This is very nice blog and I have the same problme as you described here.but still I could not resolve this problem.Actually I am developing one plug in using SmartContentSource class.I am want to upload one picure on my server for that when I make some html tag on my way.and then when it pass into GeneratePublishHtml METHOD it by default add <div> tag which I really no need and due that , that particular picture is not going to upload on my server..
till today no one could give me the solution of this might be you know the solution so you will give me.....

Thanks
Shailesh

January 9. 2010 03:09 by lubo

Hi Shailesh,
I am sorry i can't give you any advice on how to remove this <div>. There a lot of issues with WLW.

Lubo

January 21. 2010 04:05 by Bob

Hi,

my company using DotNetNuke for most of our offerings to our clients. we have tested many file upload addidtions to WLV, but none actually work. Your plug-in does publish as advertised, but when we try to upload a pdf or jpg, the file doesn't end up in the right place.

usually, the blog entry is published to the blogs directory and then a directory is created for each post. pics and other related files go in there. but when we use your upload, the files get upload but to a temp_files directory instead of the new directory for that post.

PortalRoot
--Blogs
-----3
------temp_images <-- they end up in this directory instead of the appropriate number for that post under this blog number.
------11
------12
------15 <-- this directory should get created and the file placed in there.

if we use Live Writer with its built-in picture function, everything works perfectly. the proper directory gets created and the picture file is placed there.

since this has happened with other plug-ins as well, i'm guessing this has something to do with the rights on the blog installation? i can't imanage why since the built in photo stuff is working fine. we tried to configure it as a FTP upload but decided we didn't want to give each user an FTP account with their blog. it should just work through their rights to their own blog.

any help would be great appreciated. Not just by me, but by 10,000+ DotNetNuke developers too.

Thanks in advance,

Bob

February 2. 2010 03:05 by lubo

Hi Bob,
The problem you described is in WLW itself. The plugin doesn't choose the folder where the upload will happen. It's WLW that tell the plugin the file destination. If the build in photo upload is working i guess its not written as a standart plugin as Attach File and other plugins are.

September 2. 2010 17:52 by iskbank.com

Pingback from iskbank.com
Eve Isk, Eve Ships

September 6. 2010 12:18 by Jordan 10

That's some inspirational stuff. In no way knew that opinions may very well be this diverse. Thank you for every one of the enthusiasm to supply such very helpful facts right here. I’m basically rather interested so will maintain an eye out for updates!

Add comment


 

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]


Live preview

September 6. 2010 21:22 by