培天王 发表于 2015-9-29 09:26:36

【SharePoint】File Name, Length, Size and Invalid Character Restrictions and Recom

  原文链接:http://blogs.msdn.com/joelo/archive/2007/06/27/file-name-length-size-and-invalid-character-restrictions-and-recommendations.aspx
  
  
  Something that often comes up in deployments and migrations is what is allowed?What characters are supported.Rather than saying what's supported, it's a lot easier to say what is blocked and what is not allowed.Going from a desktop, file share or public folder, or other platform there are some key considerations in knowing what works and what doesn't.Windows itself supports pretty much anything as far as characters, but still has limits on file length.Of course URLs themselves have limits in the browser and since SharePoint is a web platform, and uses the same standards, there are rules to help it act as a better web application and will avoid you getting into trouble especially from a security perspective.I say security because a lot of the invalid characters are things that would be used to do a DOS attack or attempt to hack a web server and causeexceptions.
  
  Starting simply with lengths...

[*]File and folder name lengths cannot be longer than 128 Characters in both WSS 2.0 and WSS 3.0.
[*]Link list items are restricted to 256 characters and will truncate links to SharePoint documents (or anything else) with lengths longer than this.
[*]When storing files the structure and files (entire path including sites, folders, and file name) cannot add up to more than 260 characters or they will see an error message or form validation error with the explanation around the URL length.
  In a nutshell... Use short web app names, short site collection names (avoid strings of names), and use descriptive but short file names.Some people have purposefully removed "Shared Documents" out of the team site template or used a blank template to encourage unique, and encouraged shorter document library names.I don't have a problem with "Shared Documents" since you know where it is and what it is for, but sites in sites in sites, can lead to long URLs.
  
  What can you use?From MSDN... File names can contain ASCII letters, numbers, periods, underscores, or dashes.
  
  One of the powerful mechanisms for keeping scripts, executables, and simply information you want to keep off your platform is the blocked files.This list originated from Outlook's list of blocked file types.WSS 3.0/SharePoint Server 2007 Blocked File Types List
  
  New Blocked File Types
  If you were familiar with the WSS 2.0 list, there are some new Blocked File Types: .asmx, .rem, .resx, .soap, or .ashx.If they existed before upgrade they are no longer visible or cannot be opened after upgrade.These file extensions have been added to the list of blocked file extensions.
  
  You now have the ability to make differences between farm wide blocked file types and web application blocked file types.If you want to un block it, it needs to be removed at both farm and application levels, but you can add specific blocked files for a single web application.The farm level block list for example will override anything removed at the web application level.
  
  My most commonly removed blocked files are .chm (help files), .lnk (url link), .url (url link)
  
  My most commonly added blocked files are .mp3 (audio), .pst (mail), .vhd (virtual hard drive)
  
  Invalid Characters in WSS and MOSS KB, WSS FAQ has a good FAQ article on character restrictions as well, based on the WSS Admin guide.
  
  Summary from the KB and Eric:
  
  Site Names
  
  路         In WSS Site Names may not contain the following characters: \ / : * ? " < > | # { } % & <TAB>" ~ +
  路         You cannot start a site name, subsite name, or a site group name with an underscore (_) character or with the period character (I recommend avoiding the (_) underscore in site names)
  路         You cannot use the period character consecutively in the middle of a site name
  路         You cannot use the period character at the end of a site name
  
  File Names
  
  路         Invalid characters: " # % & * : < > ? \ / { | } ~ 
  路         Cannot be longer than 128 characters
  路         You cannot use the period character consecutively in the middle of a file name
  路         You cannot use the period character at the end of a file name
  路         You cannot start a file name with the period character
  
  
  Folder Names
  
  路         You cannot use the following characters anywhere in a folder name or a server name: ~ # % & * { } \ : < > ? / | "
  路         Cannot be longer than 128 characters
  路         You cannot use the period character consecutively in the middle of a folder name
  路         You cannot use the period character at the end of a folder name
  路         You cannot start a folder name with the period character
  
  The most common ones I've seen are the & and the #, when doing uploads from file servers this list of invalid characters are the most common failure for upload beyond file size.    Replacing these characters with underscores was what would happen with V1 to V2 smigrate upgrades.But underscores are not a good idea for site names.I'd discourage it or block it.
  
  Using multi file upload UI will fail based on my experience if all of the files being uploaded are greater than the single maximum file upload restriction.It will fail gracefully with an error saying you've passed the maximum file upload limit.To upload large numbers of files using the command line to a UNC of the Web DAV location will work more reliably, but using robocopy with the logging option will allow you to see what files failed to upload such as those with invalid characters or over size.Here's a good post on using the UNC to programatically uploading files to SharePoint as well as another uploading files with code using the filestream object.
  
  Eric of Office Zealot has a good post and shares some of his experiences on blocked file types and usage of characters in document libraries.One example that I enjoy is his explanation on limit on titles.If you use numbers the limit is 49.If you use letters and spaces you can get up to 69.
   If you need to allow users to upload or download files with these extensions, you can remove the entries for these extensions from the list. For more information about managing blocked file extensions, see the topic Manage blocked file types in the Windows SharePoint Services 3.0 Central Administration Help system.
  Let me lend some of my experience as well.In WSS 2.0 especially, you could sometimes upload files with invalid characters through the Web DAV, Web Folders interface that you couldn't through the UI.I don't recommend doing this, but be aware if you did do this, it may be problematic to then later edit that file.
  With blocked file types, if you remove them to allow a large migration and then add them back, this may be a great way of quickly getting information into the sites.Unfortunately if you have a file on your site that is a blocked file type, that file cannot be edited or downloaded.
  Some might think if you block .mp3 files, if the file extension is renamed it to MPX it would still block the .mp3 file.This is not correct.The SharePoint blocked file types is simply a file extension blocker.If you need to block files based on the content you'll need to use a product like ForeFront Security for SharePoint.It can also block files that contain bad language or terms you configure with it's content filtering mechanism.
  Max File Upload/Download Sizes
  
  The default max single file upload size is 50 MB by default for a web application.Microsoft IT limits their environment at 100 MB, and the maximum that the product itself can handle or support is 2GB which is essentially a SQL limit.By setting the limit to blank will essentially support what SQL will support.It's true that simply removing this, it doesn't mean that a user can upload a 2GB file.The server time out settings, browser and network speed play a large part in what is truly supportable.The 50MB is the best experience, but it's not uncommon for a large Excel file to be 60MB for example.I recommend using 50MB - 100MB for the best user experience, but for departmental solutions working with large autocad files for example could support 200-500MB on a LAN.Downloading those same files over large distances can cause a timeout.I did a breakdown on various levels of performance and capacity in this post... deployment capacity planning.Rohit has a great example for how to programatically upload or download documents with DAV Helper and get around the timeout issues.
  Configuring Large File Support
  This snippet from an article on Configuring Large File Support in relation to some fixes in SP2 of WSS 2.0 relate very closely with your WSS 3.0 or MOSS farm when configuring your WFEs/farm to support large files.You likely won't find this documentation elsewhere.
  From the article on office.microsoft.com:
  The biggest change included in Windows SharePoint Services SP1 is the support for uploading large files. By default, the maximum size for uploading files is set to 50 MB. If you need to be able to upload larger files (such as when you use smigrate.exe to migrate a site between servers), you can change this setting to any value up to 2 GB (2047 MB).
  To configure large file support you must increase the default upload size in SharePoint Central Administration. You may also need to perform the following additional actions (depending on your hardware configuration):

[*]Tune the Microsoft Internet Information Services (IIS) connection timeout setting.   The default timeout for connections in IIS is 120 seconds (2 minutes). Depending on your maximum file size and how long it takes for the file to be uploaded, you may not need to change this setting. If, however, IIS is timing out when you upload large files, you can change this property to ensure that larger files can be uploaded successfully.
[*]Increase the default chunk size for large files.   The large-file-chunk-size property sets the amount of data that can be read from server running SQL Server at one time. If you have a file that is greater than your chunk size (such as 70 MB when the chunk size is set to 5 MB), the file would be read in 14 chunks (70 / 5). The chunk size is not related to the maximum upload file size. The chunk size simply specifies the amount of data that can be read from a file at one time. By default, the large-file-chunk-size property is set to 5 MB. If you notice performance or scale problems on the client or server, then you may need to tune this setting to get the performance you are targeting. Note that if you raise the chunk size too high, the files might use up too much front-end memory and you may need to lower this setting.
[*]Increase the maximum size limit for Web Parts.   By default, the maximum size limit for a Web Part is 1 MB. If you need to accomodate large Web Parts, you can change this setting in the web.config file for your server or servers running Windows SharePoint Services.
Increase the maximum upload size
  (I believe these are for WSS 2.0)

[*]Click Start, point to All Programs, point to Administrative Tools, and then click SharePoint Central Administration.
[*]Under Virtual Server Configuration, click Configure virtual server settings.
[*]On the Virtual Server List page, click the virtual server you want to change.
[*]On the Virtual Server Settings page, under Virtual Server Management, click Virtual server general settings.
[*]Under Maximum upload size, type the maximum file size (in MB) that you want to allow to be uploaded.
[*]Click OK.
  <update>
  Thanks Jason (from comments) for these:
  1. Get into the SharePoint Central Administration Site
  2. Select "Application Management"
  3. Under the "SharePoint Web Application Management" section select "Web Application General Settings"
  4. Change the "Maximum Upload Size"
  </update>
  If IIS is timing out when you upload large files, you can configure the Connection timeout setting in IIS to allow more than the default 120 seconds (2 minutes).
Tune the IIS connection timeout

[*]Click Start, point to All Programs, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
[*]Right-click the virtual server you want to configure, and then click Properties.
[*]Click the Web Site tab.
[*]In the Connections section, in the Connection timeout box, type the number of seconds you want IIS to wait before timing out.
[*]Click OK.

Increase the default chunk size for large files
  The large鈥揻ile鈥揷hunk鈥搒ize property must be set from the command line. This property is configured for a server or server farm, and cannot be configured for an individual virtual server. To set this property, use the following syntax:
  Stsadm.exe 鈥搊 setproperty 鈥損n large鈥揻ile鈥揷hunk鈥搒ize 鈥損v <size in bytes>.
  After making a change to this property, you must restart IIS. You can restart IIS by typing iisreset on the command line.
Increase the maximum limit for Web Parts
  This change is required only when working with large Web Parts. The maximum limit for Web Parts is set to 1048576 bytes by default.

[*]On your server computer running Windows SharePoint Services, open Notepad.
[*]In Notepad, navigate to the %HomeDrive%\Inetpub\wwwroot folder and open the web.config file.
[*]Locate the PropertySize attribute in the configuration\SharePoint\WebPartLimits element.
[*]Change the PropertySize attribute to the maximum size you need.
[*]Save and close the web.config file.
  Large file support limitations
  The following features do not support files larger than 50 MB:

[*]Virus checking. (Joel: I do believe this is the case.It's true as well that files over 16MB by default are not indexed, this can be changed.)
[*]Picture libraries (Joel: really?)
[*]Streaming files (Joel: We don't support streaming files anyway do we?Love for someone to explain this one.)
[*]Site templates (limit of 10 MB Joel: Only in WSS 2.0, this is deafult and can be increased in WSS 3.0).
  This KB "Error message when you try to upload a large file to a document library on a Windows SharePoint Services 3.0 site: "Request timed out"" has some great info on configuring the server to allow larger file sizes and increasing the time out limits.Caution!Whenever you increase timouts, you are essentially increasing the length of sessions and you'll have more concurrent sessions.
  Increase the maximum upload size
1. Click Start, point to All Programs, point to Administrative Tools, and then click SharePoint Central Administration.
2. Under Virtual Server Configuration, click Configure virtual server settings. On the Virtual Server List page, click the virtual server that you want to change.
3. On the Virtual Server Settings page, under Virtual Server Management, click Virtual server general settings.
4. Under Maximum upload size, type the maximum file size in megabytes that you want, and then click OK. You can specify a maximum file size up to 2,047 megabytes.
  
Increase the connection time-out setting
By default, the IIS connection time-out setting is 120 seconds. To increase the connection time-out setting, follow these steps: 1. Click Start, point to All Programs, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
2. Right-click the virtual server that you want to configure, and then click Properties.
3. Click the Web Site tab. Under Connections, type the number of seconds that you want in the Connection time-out box, and then click OK.
  Add the executionTimeout value
1. Use Notepad to open the Web.config file.
  By default, this file is in the following location:
Program Files\Common Files\Microsoft Shared\Web server extensions\12\TEMPLATE\LAYOUTS
2. Add the executionTimeout value that you want. For example, replace the value as follows.
  Existing code
<location path="upload.aspx">
    <system.web>
      <httpRuntime maxRequestLength="2097151" />
    </system.web>
</location>
Replacement code
<location path="upload.aspx">
    <system.web>
      <httpRuntime executionTimeout="999999" maxRequestLength="2097151" />
    </system.web>
</location>

3. After you change the file, click Save on the File menu.
4. Use Notepad to open the Web application Web.config file. By default, this file is in the following folder:
Inetpub\wwwroot\wss\VirtualDirectories\VirtualDirectoryFolder
5. Change the following line in the file.
  Existing line
<httpRuntime maxRequestLength="51200" />
Replacement line
<httpRuntime executionTimeout="999999" maxRequestLength="51200" />
  
6. After you change the file, click Save on the File menu.
7. Exit Notepad.
  
页: [1]
查看完整版本: 【SharePoint】File Name, Length, Size and Invalid Character Restrictions and Recom