Home > SharePoint 2010 > Add new file type in SharePoint

Add new file type in SharePoint


Out of the box, SharePoint can manage lot of file type. This management include the capability to show an Icon, to index, to open from browser and finally to Index. But what if you need to manage another file type?

There are 2 steps to complete:

  • Specify Icon File and activeX control to use for extraction/archiving
  • Allow Content Type to open from Internet Explorer

In this example I’ll use keepass, a pretty useful password manager, file format to enable to SharePoint

Before :

I added a KDBX file into a SharePoint Library (my Preciious.kdbx), there is no icon, Internet Explorer only allow saving, no opening… Poorly integrated.

Image Icon and Opening

First step is to add a File icon in 14/Template/Images folder. My recommendation is to use a .PNG 16×16 pixel PNG picture with transparency.

Now next step consist in register this picture. To do this edit file 14\TEMPLATE\XML\DOCICON.XML, and add this line somewhere in the <ByExtension> section:
<Mapping Key=kdbx Value=KeePass_icon.png EditText=Keepass Password Manager  />

This associate the file extension .kdbx to the KeePass_Icon.png image. Optionally you can specify the text to add to contextual menu (what we did here) and even specify an ActiveX Control to fire when opening document. But in our case, we don’t have any ActiveX to call. (More info Here ).

Well this what we have so far (mind the EditText value):

Allow Content type opening

So, our file type now have an Icon. That’s great, but you still can’t open file directly from SharePoint: Internet Explorer do not allow open file :

That’s because SharePoint by default, send specific HTTP Header when transmitting file that have not recognized Mime type. The get rid of this, there is two option:

The best you can declare document mime type as “downloadable“. That’s easy when you are working with specific content type but .kbdx file do not have specific mime type. No problem, let’s create a custom Mime type on IIS server ! Here is how to do:

Open IIS console, select server node and open “MIME Types” menu

Then click “add…” button to declare de specific Mime type. Custom mime type should begin with application/vnd. OK, it’s time to be creative:

Now, last step is to declare this Mime type as “Downloadable” this can be done via a PowerShell cmdlet:

$web=Get-SPWebApplication -Identity <WebApplication>
$web.AllowedInlineDownloadedMimeTypes.Add(“<Custom Mime Type>”)
$web.Update()

Declaring custom MIME type and set it as downloadable is not mandatory, another solution is to set the “Browser file Handling” option to “permissive” in Web Application general settings (Central Admin/Manage Web Applications/<Web application>/ General Settings application)

This is quick, but not really secure, I really suggest that you choose first option.

And voila! You are now able to open file directly from SharePoint. Of course it support Extraction/Archiving

Ressources:

Advertisements
Categories: SharePoint 2010
  1. Jesse
    June 25, 2012 at 6:23 pm

    This is EXACTLY what I was looking for, even though I got here searching for “sharepoint check out by filetype” since Sharepoint was saving a temporary KeePass file unless I performed a checkout. Thank you so much!

  2. Robert Shahon
    August 15, 2012 at 4:07 pm

    Hello this is really great but I am having issues with the icon entry. For some reason the KeePass_icon.png is not being recognised and just giving me /_layouts/images/icgen.gif.
    I have ran IISRESET but not re-booted the server. Any ideas?

  3. Robert Shahon
    August 15, 2012 at 9:11 pm

    Actually this started working, aparently we were not done configuring the search on this site and this is what was causing the issue. New issue when you use the context menu to edit the document we get the followint error: The Document could not be opened for editing. A Microsoft SharePoint Foundation compatible application could not be found to edit the document.
    Do we have to do the ActiveX Control for this to work correctly?

    • August 28, 2012 at 12:45 am

      Hi, sorry for relay, i’m curently in vacation.
      Depending on thé file type you’re trying to add, you may havé to remove the opencontrol section in docicon.xml for this extension. I’d betterave dig this point in a next post.
      Let me Know of it helps

  4. Kevin Fowler
    May 15, 2013 at 12:17 pm

    Romain, thank you for the article. It really helped me to configure SharePoint. I have a small question. Does SP creates a new version every time you are modifying KeePass database?

    • June 28, 2013 at 11:49 am

      If you enabled versionning on the Library, it seems yes.

  5. July 16, 2013 at 12:06 pm

    Terrific post however I was wondering if you could write a litte more
    on this subject? I’d be very thankful if you could elaborate a little bit further. Bless you!

  6. Thomas Finnah
    February 21, 2014 at 1:26 pm

    Romain, thanks for the article. It´s working really fine. Many thanks.

    Best Regards, Thomas.

  7. Nehas
    April 17, 2014 at 2:24 pm

    Hi,

    Nice article, though i keep getting – ‘The Document could not be opened for editing. A Microsoft SharePoint Foundation compatible application could not be found to edit the document.’. Could you help?

    • May 7, 2014 at 11:43 pm

      Most of time, it’s because the browser could not find the right application to lauch with that document MIME type. Check that Web Server is sending the right MIME Type and that computer has a correct MIME Type association set.

  8. Dylan Nicholson
    December 12, 2014 at 1:01 am

    How can we do this via a web-based API? I’m not able to execute code or change files on the server itself.

  9. Itamar Shoham
    August 4, 2015 at 1:33 pm

    https://kerseub.wordpress.com/2012/04/23/add-new-file-type-in-sharepoint/

    thanks for the detailed information.

    On SharePoint 2013, I wanted to avoid the “Read-Only/Edit” dialog, and I’ve found that you can add `OpenControl=”” OpenApp=””` to the mapping, so that the result will look like this:

    then, the file will be immediately **downloaded**, but with _Chrome_ only.

    the problem is that **IE** will still display the ‘open/save’ dialog and I really want to avoid it and make the file to be opened immediately.

    is there a way to do it?
    thanks!

  10. Itamar Shoham
    August 4, 2015 at 2:54 pm

    As continuation to my previous post, I’ve found a way to prevent the “open/save” dialog on IE.
    to do that, I had to change some registry Items on the CLIENT side (by adding group policy):
    Windows Registry Editor Version 5.00
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\AttachmentExecute\{0002DF01-0000-0000-C000-000000000046}]
    “FullMIMENameGoesHere”=hex(0):

    to get the correct name, do the following steps:
    1. click on the file in IE
    2. press “Save”
    3. open “downloads” window
    4. right click on the downloaded file -> remove the check from “Always ask before opening this type of file”
    5. open registry folder [HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\AttachmentExecute\{0002DF01-0000-0000-C000-000000000046}]
    6. Profit

    🙂

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: