Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue_django_test
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周田
vue_django_test
Commits
3a492620
Commit
3a492620
authored
Aug 23, 2023
by
周田
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:删除没用的文件
parent
ebd02fbc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
views.py
protocol_version_manage/views.py
+16
-8
xdc.sqlite
xdc.sqlite
+0
-0
No files found.
protocol_version_manage/views.py
View file @
3a492620
...
...
@@ -84,23 +84,16 @@ class AllProtocolVersionViewSet(GenericViewSet, ListModelMixin):
@api_view
([
'POST'
])
@parser_classes
([
MultiPartParser
])
def
raw_file_upload
(
request
):
# 将上传来的文件保存下来
file_obj
=
request
.
FILES
.
get
(
'file'
)
protocol_name
=
request
.
data
.
get
(
'protocol_name'
)
version
=
request
.
data
.
get
(
'version'
)
assert
protocol_name
is
not
None
and
version
is
not
None
,
Response
(
status
=
status
.
HTTP_400_BAD_REQUEST
)
try
:
# 构建文件夹路径和文件路径
folder_path
=
os
.
path
.
join
(
settings
.
BASE_DIR
,
'protocol_raw_files'
,
protocol_name
,
version
)
if
not
os
.
path
.
exists
(
folder_path
):
os
.
makedirs
(
folder_path
)
file_path
=
os
.
path
.
join
(
folder_path
,
file_obj
.
name
)
with
open
(
file_path
,
'wb'
)
as
f
:
for
chunk
in
file_obj
.
chunks
():
f
.
write
(
chunk
)
except
Exception
as
e
:
print
(
e
)
return
Response
(
status
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
)
# 更新协议版本信息,将文件路径保存下来
protocol_versions
=
AllProtocolVersion
.
objects
.
filter
(
protocol_name
=
protocol_name
)
.
first
()
...
...
@@ -108,9 +101,24 @@ def raw_file_upload(request):
for
version_path
in
version_path_list
:
if
version_path
[
'version'
]
==
version
:
if
version_path
.
get
(
'path'
,
None
)
is
not
None
:
try
:
os
.
remove
(
version_path
[
'path'
])
except
Exception
as
e
:
print
(
e
)
return
Response
(
status
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
)
version_path
[
'path'
]
=
file_path
break
# 将上传来的文件保存下来
try
:
with
open
(
file_path
,
'wb'
)
as
f
:
for
chunk
in
file_obj
.
chunks
():
f
.
write
(
chunk
)
except
Exception
as
e
:
print
(
e
)
return
Response
(
status
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
)
# 将路径保存下来
protocol_versions
.
version_paths
=
json
.
dumps
(
version_path_list
)
protocol_versions
.
save
()
...
...
xdc.sqlite
View file @
3a492620
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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