Merge pull request #1966 from radfish/PR-py3--ui-pathlib
[setuptools packaging] Ui: extend actionFile to accept pathlib.Path
This commit is contained in:
commit
edf3cf3b65
1 changed files with 5 additions and 3 deletions
|
@ -648,17 +648,19 @@ class UiRequest(object):
|
||||||
|
|
||||||
# Stream a file to client
|
# Stream a file to client
|
||||||
def actionFile(self, file_path, block_size=64 * 1024, send_header=True, header_length=True, header_noscript=False, header_allow_ajax=False, file_size=None, file_obj=None, path_parts=None):
|
def actionFile(self, file_path, block_size=64 * 1024, send_header=True, header_length=True, header_noscript=False, header_allow_ajax=False, file_size=None, file_obj=None, path_parts=None):
|
||||||
|
file_name = os.path.basename(file_path)
|
||||||
|
|
||||||
if file_size is None:
|
if file_size is None:
|
||||||
file_size = helper.getFilesize(file_path)
|
file_size = helper.getFilesize(file_path)
|
||||||
|
|
||||||
if file_size is not None:
|
if file_size is not None:
|
||||||
# Try to figure out content type by extension
|
# Try to figure out content type by extension
|
||||||
content_type = self.getContentType(file_path)
|
content_type = self.getContentType(file_name)
|
||||||
|
|
||||||
range = self.env.get("HTTP_RANGE")
|
range = self.env.get("HTTP_RANGE")
|
||||||
range_start = None
|
range_start = None
|
||||||
|
|
||||||
is_html_file = file_path.endswith(".html")
|
is_html_file = file_name.endswith(".html")
|
||||||
if is_html_file:
|
if is_html_file:
|
||||||
header_length = False
|
header_length = False
|
||||||
|
|
||||||
|
@ -699,7 +701,7 @@ class UiRequest(object):
|
||||||
file_obj.close()
|
file_obj.close()
|
||||||
break
|
break
|
||||||
else: # File not exists
|
else: # File not exists
|
||||||
yield self.error404(file_path)
|
yield self.error404(str(file_path))
|
||||||
|
|
||||||
# On websocket connection
|
# On websocket connection
|
||||||
def actionWebsocket(self):
|
def actionWebsocket(self):
|
||||||
|
|
Loading…
Reference in a new issue