locked
Documentation for sharing html content is misleading and incorrect

    Question

  • I just spent about a week on and off just trying to get a couple of images into an html fragment that I'm trying to share from my app.  The documentation is misleading at best and wrong at worst in spots, as far as I can tell.  It would be nice to get this fixed.  Maybe this will help some other folks.

    Here is one example: http://msdn.microsoft.com/en-us/library/windows/apps/hh758310.aspx

    The basic operation is sending some fragment of html that has image references via share.  You have to set up a stream reference for each one and then set the request.data.resourceMap key to it.

    It's possible this sample works, but it sure isn't helpful for sharing images from LocalStorage.  Based on my experience I would not expect it to work as written.  After much trial and error, I found the following:

    1. Apparently you can't have spaces or slashes in the resourceMap key. I guess this makes sense in retrospect, but considering the samples which clearly show using slashes, it's not very discoverable.  This isn't the only sample with the issue.

    2. Once you have files that aren't in the root of local storage, things get tricky.  For instance the docs say to use an absolute path, but that doesn't work (you get Access Denied).  You also can't use this format "ms-appdata:///local/SomeFolder/MyImage.png".  Doesn't find the file and you get Access Denied.  What I found that does work is this format: "SomeFolder\\MyImage.png"

    3. It makes a difference whether you use forward or back slashes and how many.  Also, what works for your local path to get the file won't work for html (which makes sense, but isn't obvious from the docs).

    4. Apparently you can use whatever name for the file you want in the html img src as long as it matches the resourceMap key.  Can someone confirm?

    It would be great to have a complete example showing references to files in Local Storage, as well as some pointers on some of the gotchas above.  Hope this helps someone.

    Friday, September 21, 2012 12:59 PM

All replies

  • I got this working in a c# app, but I ran into the same problems you did. I definitely agree about the documentation. It's really lacking. Unfortunately, that seems to be very prevalent throughout the docs.
    Friday, September 21, 2012 2:13 PM