Solution# 1: Use a Feature
Here is some C# code that you can place in a feature (i.e. the SPFeatureReceiver class) that will add the appropriate file type:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
...
// To allow PDF files to be opened in the browser, make certain that the PDF file type is included
// in the list of allowed inline downloaded mime types. Without this item, the browser will always
// prompt the user to Save the document as opposed to opening the file when the user clicks on the
// PDF document's link.
if (!web.Site.WebApplication.AllowedInlineDownloadedMimeTypes.Contains(@"application/pdf"))
{
web.Site.WebApplication.AllowedInlineDownloadedMimeTypes.Add(@"application/pdf");
web.Site.WebApplication.Update();
}
...
}
Solution #2: Use Powershell
Here is a series of Powershell commands that will add the appropriate file type as well:
PS C:\Users\...> $webApp = Get-SPWebApplication http://webapplicationname
PS C:\Users...> $webapp.AllowedInlineDownloadedMimeTypes.Add("application/pdf")
PS C:\Users\...> $webapp.Update()
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.