koltyakov / gosip

⚡️ SharePoint SDK for Go
https://go.spflow.com
MIT License
140 stars 32 forks source link

Special characters in file name prevent downloading #78

Closed lllama closed 2 months ago

lllama commented 2 months ago

If my file name contains some special characters (in my case, '#') then GetFile will fail when I use ServerRelativeUrl.

Versions SharePoint Online

To Reproduce Create a file with '#' in the name and attempt to download it by passing its ServerRelativeUrl to GetFile.

Expected behavior The file to be downloaded. Instead we can a 404 error.

lllama commented 2 months ago

Ah - looks like GetFileByPath should be used to deal with this. Closing - sorry for the noise.

lllama commented 2 months ago

Looks like we still need to do some escaping ourselves, however.

koltyakov commented 2 months ago

It's not about classic and modern UI, but SharePoint version. If you need to support SharePoint 2013 or 2016 when you'd need to fallback to GetFile, otherwise with 2019 and Online no matter a UI choice you can use GetFileByPath.

cody-lettau commented 2 months ago

Okay, we have been using GetFile and plan to only support 2019 and later. So we should move to GetFileByPath? I just see the comment here about only supported in modern SharePoint (guessing that's just meaning 2019+ and not the UI).

koltyakov commented 2 months ago

It's a backend method. I believe 2019 supports it.

cody-lettau commented 2 months ago

Should we then be escaping the ServerRelativeURL on our side before making the call?

koltyakov commented 2 months ago

Yes, please. And also please report which special chars you'd got to escape, so I can extend the library underthehoods correspondingly.

cody-lettau commented 2 months ago

No luck with either approach to actually download the file content when uploaded via the modern UI (classic UI works just fine) in an on-prem 2019 SE environment. No error, just empty response being returned. Will keep digging as I'm not sure it's related to the SDK.