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
신은섭(Shin Eun Seop)
2018-06-13 20:36:58 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
31b6ca16ba25b2d8a87c4ffc49ced1e23a654675
31b6ca16
1 parent
e75a05ef
add delete file
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
4 deletions
dcloud/restful/s3_interface.py
dcloud/website/templates/website/file_list.html
dcloud/website/urls.py
dcloud/website/views.py
dcloud/restful/s3_interface.py
View file @
31b6ca1
...
...
@@ -31,24 +31,29 @@ def list_path(bucket, user, path):
return
{
'files'
:
files
}
def
upload_file
(
bucket
,
user
,
local_path
,
key
):
return
S3
.
upload_file
(
local_path
,
bucket
,
user
+
"/"
+
key
)
def
download_file
(
bucket
,
user
,
local_path
,
key
):
return
S3
.
download_file
(
bucket
,
user
+
"/"
+
key
,
local_path
)
def
delete_path
(
bucket
,
user
,
path
):
return
S3
.
delete_object
(
Bucket
=
bucket
,
Key
=
user
+
"/"
+
path
)
def
make_directory
(
bucket
,
user
,
path
):
return
S3
.
put_object
(
Bucket
=
BUCKET
,
Key
=
user
+
"/"
+
path
)
#
def
move_file
(
bucket
,
user
,
old_path
,
new_path
):
S3
.
copy_object
(
Bucket
=
bucket
,
CopySource
=
bucket
+
"/"
+
user
+
"/"
+
old_path
,
Key
=
user
+
"/"
+
new_path
)
S3
.
delete_object
(
Bucket
=
bucket
,
Key
=
user
+
"/"
+
old_path
)
return
def
copy_file
(
bucket
,
user
,
old_path
,
new_path
):
S3
.
copy_object
(
Bucket
=
bucket
,
CopySource
=
bucket
+
"/"
+
user
+
"/"
+
old_path
,
Key
=
user
+
"/"
+
new_path
)
return
...
...
dcloud/website/templates/website/file_list.html
View file @
31b6ca1
...
...
@@ -53,7 +53,7 @@
</td>
<td
class=
"center aligned collapsing"
><i
onclick=
"make_folder()"
style=
"cursor: pointer;"
class=
"sign out alternate icon"
></i></td>
<td
class=
"center aligned collapsing"
>
{% with new_path=path|add:file.name
|add:'/'
%}
{% with new_path=path|add:file.name %}
<a
href=
"{% url 'file_delete' path=new_path %}"
><i
class=
"trash alternate outline icon"
></i></a>
{% endwith %}
</td>
...
...
dcloud/website/urls.py
View file @
31b6ca1
...
...
@@ -12,7 +12,9 @@ urlpatterns = [
url
(
r'^$'
,
views
.
home
,
name
=
'home'
),
url
(
r'^list/(?P<path>([\w\s가-힣.\`\'\˜\=\+\#\ˆ\@\$\&\-\.\(\)\{\}\;\[\]]*/)*)$'
,
views
.
file_list
,
name
=
'file_list'
),
url
(
r'^upload/(?P<path>([\w\s가-힣.\`\'\˜\=\+\#\ˆ\@\$\&\-\.\(\)\{\}\;\[\]]*/)*)$'
,
views
.
file_upload
,
name
=
'file_upload'
),
url
(
r'^download/(?P<path>([\w\s가-힣.\`\'\˜\=\+\#\ˆ\@\$\&\-\.\(\)\{\}\;\[\]]*/)*)$'
,
views
.
file_download
,
name
=
'file_download'
),
url
(
r'^delete/(?P<path>([\w\s가-힣.\`\'\˜\=\+\#\ˆ\@\$\&\-\.\(\)\{\}\;\[\]]*/)*)$'
,
views
.
file_delete
,
name
=
'file_delete'
),
url
(
r'^make_folder/(?P<path>([\w\s가-힣.\`\'\˜\=\+\#\ˆ\@\$\&\-\.\(\)\{\}\;\[\]]*/)*)$'
,
views
.
make_folder
,
name
=
'make_folder'
),
url
(
r'^delete/(?P<path>([\w\s가-힣.\`\'\˜\=\+\#\ˆ\@\$\&\-\.\(\)\{\}\;\[\]]*/*)*)$'
,
views
.
file_delete
,
name
=
'file_delete'
),
url
(
r'^download/(?P<path>([\w\s가-힣.\`\'\˜\=\+\#\ˆ\@\$\&\-\.\(\)\{\}\;\[\]]*/*)*)$'
,
views
.
file_download
,
name
=
'file_download'
),
]
\ No newline at end of file
...
...
dcloud/website/views.py
View file @
31b6ca1
...
...
@@ -31,6 +31,7 @@ def file_upload(request, path):
requests
.
post
(
'http://localhost:8000/restapi/list/'
+
path
,
files
=
{
'file'
:
file
},
headers
=
headers
,
cookies
=
cookies
)
return
redirect
(
'file_list'
,
path
=
path
)
@login_required
def
make_folder
(
request
,
path
):
dir_name
=
request
.
POST
.
get
(
'dir_name'
)
cookies
=
{
'sessionid'
:
request
.
session
.
session_key
}
...
...
@@ -39,6 +40,7 @@ def make_folder(request, path):
files
=
requests
.
put
(
'http://localhost:8000/restapi/list/'
+
path
,
headers
=
headers
,
cookies
=
cookies
)
return
redirect
(
'file_list'
,
path
=
path
)
@login_required
def
file_delete
(
request
,
path
):
cookies
=
{
'sessionid'
:
request
.
session
.
session_key
}
cookies
[
'csrftoken'
]
=
csrf
.
get_token
(
request
)
...
...
@@ -46,6 +48,7 @@ def file_delete(request, path):
requests
.
delete
(
'http://localhost:8000/restapi/file/'
+
path
,
headers
=
headers
,
cookies
=
cookies
)
return
redirect
(
'file_list'
,
path
=
"/"
.
join
(
path
.
split
(
"/"
)[:
-
2
]))
@login_required
def
file_download
(
request
,
path
):
cookies
=
{
'sessionid'
:
request
.
session
.
session_key
}
requests
.
get
(
'http://localhost:8000/restapi/file/'
+
path
,
cookies
=
cookies
)
...
...
Please
register
or
login
to post a comment