Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-CloudComputing
/
A_Team_Khuloud
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Ubuntu
2020-05-20 18:43:46 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0898352fd8799e6cdda4e26f989efde8322398b3
0898352f
1 parent
55aa57f8
사용자별 버킷 생성
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
13 deletions
A_Team_Khuloud/khuloud/.gitignore
A_Team_Khuloud/khuloud/blog/__pycache__/views.cpython-37.pyc
A_Team_Khuloud/khuloud/blog/views.py
A_Team_Khuloud/khuloud/cloud/__pycache__/views.cpython-37.pyc
A_Team_Khuloud/khuloud/cloud/views.py
A_Team_Khuloud/khuloud/db.sqlite3
A_Team_Khuloud/khuloud/.gitignore
View file @
0898352
*.ini
.aws
...
...
A_Team_Khuloud/khuloud/blog/__pycache__/views.cpython-37.pyc
View file @
0898352
No preview for this file type
A_Team_Khuloud/khuloud/blog/views.py
View file @
0898352
...
...
@@ -59,6 +59,7 @@ def logout(request):
def
register
(
request
):
Cog
=
cognito
.
Cognito
()
reg
=
views
.
FileView
()
if
request
.
user
.
is_authenticated
:
raise
PermissionDenied
if
request
.
method
==
"POST"
:
require_keys
=
(
'username'
,
'password'
,
'first_name'
,
'last_name'
,
'email'
)
...
...
@@ -97,7 +98,7 @@ def register(request):
},
])
Cog
.
confirm_sign_up
(
username
=
request
.
POST
[
'username'
]);
print
(
views
.
create_bucket
)
print
(
reg
.
create_bucket
(
request
)
)
return
redirect
(
'/main'
)
else
:
return
render
(
request
,
'register.html'
,
{
...
...
A_Team_Khuloud/khuloud/cloud/__pycache__/views.cpython-37.pyc
View file @
0898352
No preview for this file type
A_Team_Khuloud/khuloud/cloud/views.py
View file @
0898352
...
...
@@ -25,10 +25,6 @@ config.read('config.ini')
# file.name
# )
# file_urls = [f"https://s3.us-ease-1.amazonaws.com/khuloud/{file.name}" for file in request.FILES.getlist('file')]
# return JsonResponse({'files':file_urls}, status=200)
class
FileView
(
View
):
#keys=aws_key()
s3_client
=
boto3
.
client
(
...
...
@@ -36,8 +32,6 @@ class FileView(View):
aws_access_key_id
=
config
[
'aws'
][
'AWS_ACCESS_KEY_ID'
],
aws_secret_access_key
=
config
[
'aws'
][
'AWS_SECRET_ACCESS_KEY'
]
)
@csrf_exempt
def
post
(
self
,
request
):
# filename = request.data.get('filename')
...
...
@@ -46,9 +40,17 @@ class FileView(View):
self
.
s3_client
.
upload_file
(
filepath
,
bucket_name
,
filepath
)
s3link
=
'https://s3.console.aws.amazon.com/s3/buckets/'
+
bucket_name
+
'/'
+
filepath
return
JsonResponse
({
'file'
:
s3link
})
@csrf_exempt
def
create_bucket
(
request
):
s3
=
boto3
.
client
(
's3'
)
s3
.
create_bucket
(
Bucket
=
'request.user.username'
)
return
Bucket
@csrf_exempt
def
create_bucket
(
self
,
request
):
"""
s3 = boto3.resource('s3',
aws_access_key_id = config['aws']['AWS_ACCESS_KEY_ID'],
aws_secret_access_key=config['aws']['AWS_SECRET_ACCESS_KEY']
)
"""
bucket
=
self
.
s3_client
.
create_bucket
(
ACL
=
'public-read-write'
,
Bucket
=
request
.
POST
[
'username'
],
CreateBucketConfiguration
=
{
'LocationConstraint'
:
'ap-northeast-2'
},
)
...
...
A_Team_Khuloud/khuloud/db.sqlite3
View file @
0898352
No preview for this file type
Please
register
or
login
to post a comment