Merge branch 'dev' of https://github.com/jh8579/fileshell_cloudcomputing into dev
# Conflicts: # fileshell/models.py # fileshell/settings.py # fileshell/urls.py # fileshell/views.py # templates/base.html
Showing
7 changed files
with
35 additions
and
20 deletions
fileshell/static/css/dropzone.css
0 → 100644
This diff is collapsed. Click to expand it.
| 1 | body { | 1 | body { |
| 2 | font-family: "Roboto", sans-serif; | 2 | font-family: "Roboto", sans-serif; |
| 3 | } | 3 | } |
| 4 | + | ||
| 4 | .search_form{ | 5 | .search_form{ |
| 5 | float:right; | 6 | float:right; |
| 6 | } | 7 | } |
| 8 | +.drop{ | ||
| 9 | + width:200px; | ||
| 10 | + height:200px; | ||
| 11 | +} | ||
| 12 | +.drop_zone{ | ||
| 13 | + width:200px; | ||
| 14 | + height:200px; | ||
| 15 | +} | ||
| 7 | .left_bar { | 16 | .left_bar { |
| 8 | float:left; | 17 | float:left; |
| 9 | width:200px; | 18 | width:200px; | ... | ... |
| ... | @@ -26,11 +26,6 @@ class MediaStorage(S3Boto3Storage): | ... | @@ -26,11 +26,6 @@ class MediaStorage(S3Boto3Storage): |
| 26 | client.upload_fileobj(nf, AWS_STORAGE_BUCKET_NAME, user.username + '/' + dir + file.name) | 26 | client.upload_fileobj(nf, AWS_STORAGE_BUCKET_NAME, user.username + '/' + dir + file.name) |
| 27 | os.remove('tempfile') | 27 | os.remove('tempfile') |
| 28 | # putResponse = client.put_object(Bucket=AWS_STORAGE_BUCKET_NAME, Key= file_name) | 28 | # putResponse = client.put_object(Bucket=AWS_STORAGE_BUCKET_NAME, Key= file_name) |
| 29 | - """ | ||
| 30 | - def download_file(file_name, dir): | ||
| 31 | - client = boto3.resource('s3') | ||
| 32 | - client.Bucket(AWS_STORAGE_BUCKET_NAME).download_file(Key= dir, Filename=LOCAL_DOWNLOAD_PATH+file_name) | ||
| 33 | - """ | ||
| 34 | 29 | ||
| 35 | def down(filename, bucketPath): | 30 | def down(filename, bucketPath): |
| 36 | session = boto3.session.Session(region_name='us-west-2') | 31 | session = boto3.session.Session(region_name='us-west-2') | ... | ... |
| ... | @@ -42,7 +42,6 @@ def file(request): | ... | @@ -42,7 +42,6 @@ def file(request): |
| 42 | type = this_path.split('/') | 42 | type = this_path.split('/') |
| 43 | type.pop(0) | 43 | type.pop(0) |
| 44 | type = type.pop(0) | 44 | type = type.pop(0) |
| 45 | - print(type) | ||
| 46 | 45 | ||
| 47 | # user가 갖고 있는 폴더 중 현재 url을 parent로 갖는 폴더 필터링 | 46 | # user가 갖고 있는 폴더 중 현재 url을 parent로 갖는 폴더 필터링 |
| 48 | folderList = Folder.objects.filter(parent__dir_name=dir, user=request.user.username) | 47 | folderList = Folder.objects.filter(parent__dir_name=dir, user=request.user.username) |
| ... | @@ -142,10 +141,10 @@ def add_folder(request): | ... | @@ -142,10 +141,10 @@ def add_folder(request): |
| 142 | 141 | ||
| 143 | def upload(request): | 142 | def upload(request): |
| 144 | if request.method == 'POST': | 143 | if request.method == 'POST': |
| 145 | - | 144 | + print(request.FILES) |
| 146 | ## 파일 model 변수 초기화 | 145 | ## 파일 model 변수 초기화 |
| 147 | - filedata = request.FILES.get('source-file') | 146 | + filedata = request.FILES.get('file') # request.Files['file'] 함수 썻을 때 오류 발생할 수 있음!! |
| 148 | - title = request.FILES.get('source-file') | 147 | + title = request.FILES.get('file') |
| 149 | user = request.user | 148 | user = request.user |
| 150 | user_name = request.user.username | 149 | user_name = request.user.username |
| 151 | now = time.localtime() | 150 | now = time.localtime() |
| ... | @@ -163,7 +162,6 @@ def upload(request): | ... | @@ -163,7 +162,6 @@ def upload(request): |
| 163 | MediaStorage.upload_file(filedata, user, dir) | 162 | MediaStorage.upload_file(filedata, user, dir) |
| 164 | else: | 163 | else: |
| 165 | pass | 164 | pass |
| 166 | - | ||
| 167 | return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/')) | 165 | return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/')) |
| 168 | 166 | ||
| 169 | def download(request, bucketPath, filename, dir): | 167 | def download(request, bucketPath, filename, dir): | ... | ... |
| ... | @@ -5,6 +5,7 @@ | ... | @@ -5,6 +5,7 @@ |
| 5 | <meta charset="utf-8"> | 5 | <meta charset="utf-8"> |
| 6 | <title> FileShell</title> | 6 | <title> FileShell</title> |
| 7 | <link rel="stylesheet" href="{% static 'css/layout_base.css' %}"> | 7 | <link rel="stylesheet" href="{% static 'css/layout_base.css' %}"> |
| 8 | + <link rel="stylesheet" href="{% static 'css/dropzone.css' %}"> | ||
| 8 | </head> | 9 | </head> |
| 9 | <body> | 10 | <body> |
| 10 | 11 | ||
| ... | @@ -22,7 +23,7 @@ | ... | @@ -22,7 +23,7 @@ |
| 22 | <a href="{% url 'logout' %}"> <img class = 'logout_icon' src= "{% static 'resources/logout.png' %}" width="50" height="50" align="right"/></a> | 23 | <a href="{% url 'logout' %}"> <img class = 'logout_icon' src= "{% static 'resources/logout.png' %}" width="50" height="50" align="right"/></a> |
| 23 | <a href="{% url 'profile' %}"> <img class = 'profile_icon' src= "{% static 'resources/profile.png' %}" width="50" height="50" align="right"/></a> | 24 | <a href="{% url 'profile' %}"> <img class = 'profile_icon' src= "{% static 'resources/profile.png' %}" width="50" height="50" align="right"/></a> |
| 24 | <div class="search_form"> | 25 | <div class="search_form"> |
| 25 | - <form id='search' action="" onsubmit="yourFunction()" method="post" enctype="multipart/form-data">{% csrf_token %} | 26 | + <form id='search' action="" onsubmit="yourFunction()" method="post" enctype="multipart/form-data" >{% csrf_token %} |
| 26 | <input type="dir_name" name="dir_name" id="dir_name" required="required" placeholder="검색할 파일이나 폴더 이름"> | 27 | <input type="dir_name" name="dir_name" id="dir_name" required="required" placeholder="검색할 파일이나 폴더 이름"> |
| 27 | <input type = "submit"> | 28 | <input type = "submit"> |
| 28 | </form> | 29 | </form> | ... | ... |
| ... | @@ -4,10 +4,8 @@ | ... | @@ -4,10 +4,8 @@ |
| 4 | <div> | 4 | <div> |
| 5 | <div class="right_bar"> | 5 | <div class="right_bar"> |
| 6 | <li class="nav-item1"><a href="" class="nav-link-right"> <img class = 'add_folder_icon' src= "{% static 'resources/upload.png' %}" width="30" height="30"/> 파일 업로드</a></li> | 6 | <li class="nav-item1"><a href="" class="nav-link-right"> <img class = 'add_folder_icon' src= "{% static 'resources/upload.png' %}" width="30" height="30"/> 파일 업로드</a></li> |
| 7 | - <form action={% url 'upload' %} method="post" enctype="multipart/form-data" novalidate> | 7 | + <form action={% url 'upload' %} method="post" enctype="multipart/form-data" novalidate>{% csrf_token %} |
| 8 | - {% csrf_token %} | 8 | + <input type ="file" name = "file"> |
| 9 | - | ||
| 10 | - <input type ="file" name = "source-file"> | ||
| 11 | <input type = "submit"> | 9 | <input type = "submit"> |
| 12 | </form> | 10 | </form> |
| 13 | <li class="nav-item1"><a href="" class="nav-link-right"> <img class = 'add_folder_icon' src= "{% static 'resources/add_folder.png' %}" width="30" height="30"/> 새 폴더</a></li> | 11 | <li class="nav-item1"><a href="" class="nav-link-right"> <img class = 'add_folder_icon' src= "{% static 'resources/add_folder.png' %}" width="30" height="30"/> 새 폴더</a></li> |
| ... | @@ -63,12 +61,30 @@ | ... | @@ -63,12 +61,30 @@ |
| 63 | {% else %} | 61 | {% else %} |
| 64 | <p>No File.</p> | 62 | <p>No File.</p> |
| 65 | {% endif %} | 63 | {% endif %} |
| 66 | - | ||
| 67 | </table> | 64 | </table> |
| 65 | + <form action="{% url 'upload' %}" id="dropzone" class="dropzone" method="post" enctype="multipart/form-data">{% csrf_token %} | ||
| 66 | + <div class="fallback"> | ||
| 67 | + <input class="fall_back" name="source-file" type="file"/> | ||
| 68 | + </div> | ||
| 69 | + </form> | ||
| 68 | </div> | 70 | </div> |
| 69 | </div> | 71 | </div> |
| 70 | <!-- //container --> | 72 | <!-- //container --> |
| 71 | </div> | 73 | </div> |
| 72 | <!-- //frame --> | 74 | <!-- //frame --> |
| 73 | 75 | ||
| 76 | + <script src="{% static 'js/dropzone.js' %}"></script> | ||
| 77 | + <script type="text/javascript"> | ||
| 78 | + Dropzone.options.dropzone = { | ||
| 79 | + maxFilesize: 10, // Mb | ||
| 80 | + init: function() { | ||
| 81 | + this.on('success', function(){ | ||
| 82 | + if (this.getQueuedFiles().length == 0 && this.getUploadingFiles().length == 0) { | ||
| 83 | + location.reload(); | ||
| 84 | + } | ||
| 85 | + }); | ||
| 86 | + } | ||
| 87 | + }; | ||
| 88 | + </script> | ||
| 89 | + | ||
| 74 | {% endblock %} | 90 | {% endblock %} |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -6,10 +6,6 @@ | ... | @@ -6,10 +6,6 @@ |
| 6 | <div class="container"> | 6 | <div class="container"> |
| 7 | <!-- //nav --> | 7 | <!-- //nav --> |
| 8 | <div class="content"> | 8 | <div class="content"> |
| 9 | - <div class="well text-muted text-center" style="padding-top: 4rem; padding-bottom: 4rem;"> | ||
| 10 | - <span class="glyphicon glyphicon-arrow-down" style="font-size: 4rem;"></span> | ||
| 11 | - <h3>Drop Photos Here to Upload</h3> | ||
| 12 | - </div> | ||
| 13 | <h2>즐겨찾기</h2> | 9 | <h2>즐겨찾기</h2> |
| 14 | <table cellspacing=1 width=700 border=1> | 10 | <table cellspacing=1 width=700 border=1> |
| 15 | <tr> | 11 | <tr> | ... | ... |
-
Please register or login to post a comment