Toggle navigation
Toggle navigation
This project
Loading...
Sign in
신은섭(Shin Eun Seop)
/
2018-1-d.cloud
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
10
Merge Requests
0
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Kangsubeen
2018-06-14 04:57:40 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e69b98e20a14dd5e76651e165afd8e8fb7f99be4
e69b98e2
1 parent
11f34e17
delete file in media
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletions
dcloud/restful/views.py
dcloud/restful/views.py
View file @
e69b98e
...
...
@@ -5,7 +5,7 @@ from rest_framework.response import Response
from
rest_framework
import
status
from
rest_framework.authentication
import
SessionAuthentication
,
BasicAuthentication
from
rest_framework.permissions
import
IsAuthenticated
import
os
from
restful
import
s3_interface
from
restful.models
import
File
...
...
@@ -39,6 +39,8 @@ class FileList(APIView):
file_path
=
'.'
+
file_serializer
.
data
.
get
(
'file'
)
user
=
request
.
user
data
=
s3_interface
.
upload_file
(
s3_interface
.
BUCKET
,
user
.
username
,
file_path
,
path
+
file_path
.
split
(
'/'
)[
-
1
])
if
os
.
path
.
exists
(
file_path
):
os
.
remove
(
file_path
)
# TODO upload check
# TODO remove local file
return
Response
(
file_serializer
.
data
,
status
=
status
.
HTTP_201_CREATED
)
...
...
@@ -66,6 +68,8 @@ class FileDetail(APIView):
file
=
'media/'
+
path
.
split
(
'/'
)[
-
1
]
user
=
request
.
user
s3_interface
.
download_file
(
s3_interface
.
BUCKET
,
user
.
username
,
file
,
path
)
if
os
.
path
.
exists
(
file
):
os
.
remove
(
file
)
# TODO error
return
Response
({
'file'
:
file
})
...
...
Please
register
or
login
to post a comment