How to overcome limitation of file name or limit on length of url in sharepoint


I have a backup of data from client. which contains files of various format ex: .pdf, .doc, .xlsx

File name is also large. i created an utility to upload those files to sharepoint but i get an exception file name or folder name can exceed 160 char....

I know complete url length could exceed more than 260 chars and client can not compromise with changing file names as its about to change 50 gb files. How could i overcome this situation?

Is there any way to encrypt file while uploading and when get uploaded show original name. and when comes url show some encrypted this or any good option i can do.

Please reply!


February 14th, 2014 11:09pm

Here is a link to the exact limitations

There is no way to really overcome these limitations.  The limitations are there to make room for all of what sharepoint does with a url while keeping in mind the URL'S limitation which is not sharepoints fault.

Your only real option is to either rename all the files, or develop a custom Url Rewriter with a custom upload page on the files.

E.g. Modify your utility to build an Xml File of all the file names and give them short names, something like this

  <OldName>Really long name here.pdf</OldName>


Upload the file as P_0001.PDF, 

Then create an HttpModule that intercepts requests to either OldName or ShortName and retrieves P_0001.PDF (the short name) and design it in such a way that it catches link tags to, e.g. if someone creates a link to "Really long name here.pdf" it loads P_0001.PDF.

To make this prettier,  You could create a custom FieldType called LongFileMapFieldType and design it to be a hidden field.

Then create a document library in visual studio with a column on it based on the custom field type (Have it inherit from multi line text).  Then modify the upload form on the document library to make the xml map and rename the file and save the xml in the Custom Field type on the uploaded list item and the files bytes in the File.

Put the HttpModule in the same solution with an SPWebConfigModification to automate the whole process.

Then you can go to your custom document library and upload long name files to it, but only it.

Sounds involved, and is, but I can't think of any other way to do it unless you can get Asp.Net Url Rewriting to handle your problem.


Was just thinking that users might want to rename P_0001.PDF to make more sense and in doing so would break the Url Rewriter.  So you could go a step further and add Event Handlers to the List so that when the item is updated (e.g. it's Name Column) you update the Xml Map so the HttpModule doesn't break.

Free Windows Admin Tool Kit Click here and download it now
February 16th, 2014 3:14am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics