koltyakov / sppull

📎 Download files from SharePoint document libraries using Node.js without hassles
MIT License
46 stars 16 forks source link

Cannot find file in SharePoint with % in filename #53

Closed Tiago-Altus closed 4 years ago

Tiago-Altus commented 4 years ago

sppull version 2.6.6

I am trying to download a filename called "hello%.txt" from SharePoint using sppull. In the sppull options I tried the 2 following ways: Encoded the file name

const sppullOptions = {
     spRootFolder: spFolder,      
     dlRootFolder: downloadPath,  
     strictObjects: [encodeURIComponent("hello%.txt")],  
     muteConsole: true
};

Non-encoded file name

const sppullOptions = {
     spRootFolder: spFolder,      
     dlRootFolder: downloadPath,  
     strictObjects: ["hello%.txt"],  
     muteConsole: true
};

When I encode I get the error: The file /pathtofile/hello%25.txt does not exist Without encoding I get the error: Unable to pull from SharePoint: TypeError: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined'

Any ideas if % is supported with sppull, or am I getting something wrong with the sppull options?

koltyakov commented 4 years ago

Hey @Tiago-Altus,

Either encodeURIComponent or %25 works for me.

screencast 2020-08-14 21-12-27

Tiago-Altus commented 4 years ago

@koltyakov Interesting... you see, my file also downloads to the specified download path but when I open the file it has error xml written in it.. It says the following in the hello%.txt file: <?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code>-2130575338, Microsoft.SharePoint.SPException</m:code><m:message xml:lang="en-US">The file /sites/pathtosite/Shared Documents/path/hello%25.txt does not exist.</m:message></m:error>

Does sppull use ServerRelativeUrl or ServerRelativePath? I think if it used ServerRelativePath with [decodedUrl] this may work.

koltyakov commented 4 years ago

It uses ServerRelativePath and ServerRelativeUrl as a fallback method (for SP versions which didn't have *Path methods). Oh, I'm getting the same behavior with XML error body, as I randomly picked an svg file by a brief look at the body I false positively considered it was ok. Will check.

koltyakov commented 4 years ago

@Tiago-Altus, seems I've nailed the issue, please check just published sppull@2.6.7. Does it work for you?

Tiago-Altus commented 4 years ago

Yep, it works now.