Commit 32b5d7b7 authored by Wei Shoulin's avatar Wei Shoulin
Browse files

down url

parent 219ef48e
from .version import __version__ from .version import __version__
from .common import request, fs from .common import request
from io import BytesIO from io import BytesIO
from .exceptions.exception import AppError from .exceptions.exception import AppError
__all__ = [ __all__ = [
...@@ -20,7 +20,7 @@ def download_file(file_path: str) -> bytes: ...@@ -20,7 +20,7 @@ def download_file(file_path: str) -> bytes:
Raises: Raises:
Exception: 如果下载失败,则抛出异常AppError。 Exception: 如果下载失败,则抛出异常AppError。
""" """
response = request.download_file(f"/common/download/file?file_path={file_path}") response = request.download_file(f"/api/common/download/file?file_path={file_path}")
if not response.ok: if not response.ok:
raise AppError("Failed to download the file. Reason: " + response.reason) raise AppError("Failed to download the file. Reason: " + response.reason)
return response.content return response.content
...@@ -38,6 +38,7 @@ def read_file(file_path: str) -> BytesIO: ...@@ -38,6 +38,7 @@ def read_file(file_path: str) -> BytesIO:
Raises: Raises:
Exception: 如果读取失败,则抛出异常AppError。 Exception: 如果读取失败,则抛出异常AppError。
""" """
from .common import fs
with fs.get_file_storage().read_file(file_path) as iobytes_io: with fs.get_file_storage().read_file(file_path) as iobytes_io:
try: try:
iobytes_io.seek(0) iobytes_io.seek(0)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment