Skip to content

Commit 1d7f3d9

Browse files
authored
Merge pull request #300 from kraptor/master
Correctly support weird characters in filenames when downloading
2 parents 1af45f9 + ed0c44a commit 1d7f3d9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

office365/sharepoint/actions/download_file.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from office365.runtime.http.http_method import HttpMethod
2+
from office365.runtime.odata.odata_path_parser import ODataPathParser
23
from office365.runtime.queries.service_operation_query import ServiceOperationQuery
34

45

@@ -23,5 +24,9 @@ def _process_response(response):
2324
"""
2425
file_object.write(response.content)
2526

26-
super(DownloadFileQuery, self).__init__(web, r"getFileByServerRelativeUrl('{0}')/\$value".format(file_url))
27+
# Sharepoint Endpoint bug: https://github.com/SharePoint/sp-dev-docs/issues/2630
28+
file_url = ODataPathParser.encode_method_value(file_url)
29+
30+
super(DownloadFileQuery, self).__init__(web, r"getFileByServerRelativePath(decodedurl={0})/$value".format(file_url))
31+
2732
self.context.before_execute(_construct_download_query)

0 commit comments

Comments
 (0)