Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-dfs
csst-dfs-client
Commits
32b5d7b7
Commit
32b5d7b7
authored
Dec 25, 2024
by
Wei Shoulin
Browse files
down url
parent
219ef48e
Changes
1
Hide whitespace changes
Inline
Side-by-side
csst_dfs_client/__init__.py
View file @
32b5d7b7
from
.version
import
__version__
from
.common
import
request
,
fs
from
.common
import
request
from
io
import
BytesIO
from
.exceptions.exception
import
AppError
__all__
=
[
...
...
@@ -20,7 +20,7 @@ def download_file(file_path: str) -> bytes:
Raises:
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
:
raise
AppError
(
"Failed to download the file. Reason: "
+
response
.
reason
)
return
response
.
content
...
...
@@ -38,6 +38,7 @@ def read_file(file_path: str) -> BytesIO:
Raises:
Exception: 如果读取失败,则抛出异常AppError。
"""
from
.common
import
fs
with
fs
.
get_file_storage
().
read_file
(
file_path
)
as
iobytes_io
:
try
:
iobytes_io
.
seek
(
0
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment