Forum Discussion
SharePoint Online support for # and % in file names
I'm probably not of much use for the CSOM problem in reference to '#' characters etc. I know it's a problem since when I'm building node projects from a one-drive folder it generates a bunch of # folders for node modules and this causes sync issues with One-Drive. I heard from someone else in my team that they're supposedly adding '#' support for file-systems but I'm sure someone else can verify when and if this is happening/has happended.
What I can say is that you can trust URL encoding. A filename with the name 'File%20Name' would appear as 'File%2520Name' as % is encoded to %25. Just encode and decode and you should end up with something reliable. Also # is encoded as %23.
- Aaron Robertson-HodderNov 12, 2017Copper ContributorThanks for your reply Charles, but it's not that simple. I have three files in a SharePoint Document Library, named "test%file.jpg", "test%20file.jpg" and "test file.jpg".
Using REST and the GetFileByServerRelativeUrl method the only file I can access is "test file". If I try and access "test%20file.jpg" without encoding I get the results for "test file.jpg" which makes sense.
However, if I encode the % (so using "test%2520file.jpg") I still get the results for "test file.jpg". No matter what permutation of encoding I use, I cannot access either of the files with % in the name.- Charles PritchardNov 13, 2017Copper Contributor
Testing this myself now, I am unable to upload any files containing a '%' so I can't run through this exact scenario but I know that all three of those filenames you suggest are unique as long as they're encoded and then decoded. Can I ask where you have the ability to upload a file with a '%' in the name?
Either way, if you are making a call to the endpoint for 'test%2520file' it should absolutely return 'test%20file' and if that is not the case then SharePoint may not be behaving as expected. Maybe some double encoding might be a work around? I'm not sure If SP tries to parse any other forms of encoding when using the REST service.
- Aaron Robertson-HodderNov 14, 2017Copper ContributorYou will only be able to if support for these characters is enabled in your tenant. See the following link for details:
https://blogs.technet.microsoft.com/wbaer/2017/04/06/new-support-for-and-in-sharepoint-online-and-onedrive-for-business/