leeseohyeon

.

1 { 1 {
2 - "accessKeyId": "ASIAZQ5XTMMFXPQFN3NS", 2 + "accessKeyId": "ASIAXZL2SWFE22KE6FMR",
3 - "secretAccessKey": "TcMI1ZR/XCHWTp+RXbXDYmoUUb589qOEKVCgrp9s", 3 + "secretAccessKey": "xicAWumxI045y2H/gpvHj931ejPAxKx05z3s7306",
4 - "sessionToken": "FwoGZXIvYXdzENb//////////wEaDNgXTHMODoBOdUpzkCLDAbECc2/FubNowruTAgVlYoP1DSxpCPyKWCZAgNyMak8XUFwQycZDMvPgj/hl+Jn+a8yn2xktkSZP3yRQ2UcTm0WQeWKt94HzatAXBT17B2BBLZOPjMgFWiG4Rgqw48tyT5po3/M84gs5p+x/0AGh7oVQ9VlqoZcgdCRfXUBD9oQ7xkb74AiZ6kZKu5DSNMyIhzzXFrtIXMK+0La9AmfuAhytmTlG9XXp1UhYzubBajB6b2OW/Ce4yKs7Y7UzRr3LERyLCCj9zM72BTIt+BGOkTrbTV65QeFYRmPbKB7OlRsIfdyd67uKLQfSGmsSgp0SFw7sZKcRRODL", 4 + "sessionToken": "FwoGZXIvYXdzENT//////////wEaDMjAgd73D8cgPHM6cCLDARgKnP64irW5N1G56jblgQgjgf58Xwfr/Ysghx6udQ0sS5St5XOtnc/nMqukHOc//gqPaSgNZza57fmaIQVdTM8dgSbM6a72SbXirYO38YDfzHCQz73gg2DWAjrZy2RDu1v8lmshh3393B9MuZFEEJzDgsLgNAmQmP5iULRVqnVqRhUcuhMxFz91nsSuts1u0r41sBZTEwKjE3Qnor3PrUS7KKeZqi8axod4jEwLCDj+CW6N2l5I8QeXtanrKnHGVL4NiiiJlc72BTIt1pHEnchZvLii96Afs5ThV/018vTKHgqZl7m/QGHCVc5hwcNOU6MLnwSLHFYf",
5 "region": "us-east-1" 5 "region": "us-east-1"
6 -}
...\ No newline at end of file ...\ No newline at end of file
6 +}
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
17 var AWS = require('aws-sdk'); 17 var AWS = require('aws-sdk');
18 AWS.config.update({ region: 'ap-northeast-2' }); 18 AWS.config.update({ region: 'ap-northeast-2' });
19 19
20 -var BUCKET_NAME = 'dkhuloud'; 20 +var BUCKET_NAME = 'qkrrlqja-test';
21 21
22 var s3 = new AWS.S3(); 22 var s3 = new AWS.S3();
23 var fs = require('fs'); 23 var fs = require('fs');
...@@ -230,7 +230,7 @@ var S3 = { ...@@ -230,7 +230,7 @@ var S3 = {
230 sourceFile = sourceFile.split('(')[0] + '(' + lvNum.toString() + ')' + sourceFile.split(')')[1]; 230 sourceFile = sourceFile.split('(')[0] + '(' + lvNum.toString() + ')' + sourceFile.split(')')[1];
231 } 231 }
232 console.log('makeVersion ', sourceFile); 232 console.log('makeVersion ', sourceFile);
233 - 233 +
234 callback(true, sourceFile); 234 callback(true, sourceFile);
235 }, 235 },
236 236
...@@ -348,7 +348,7 @@ var S3 = { ...@@ -348,7 +348,7 @@ var S3 = {
348 var makeFolder = function(dir, callback){ 348 var makeFolder = function(dir, callback){
349 var paths = dir.substring(__dirname.length+1); // download/userId/folder1/folder2/test.txt 349 var paths = dir.substring(__dirname.length+1); // download/userId/folder1/folder2/test.txt
350 paths = paths.split('/'); 350 paths = paths.split('/');
351 - 351 +
352 var folders = __dirname; 352 var folders = __dirname;
353 for(var i=0; i<paths.length-1; i++){ 353 for(var i=0; i<paths.length-1; i++){
354 folders += '/'+paths[i]; 354 folders += '/'+paths[i];
...@@ -364,4 +364,4 @@ var makeFolder = function(dir, callback){ ...@@ -364,4 +364,4 @@ var makeFolder = function(dir, callback){
364 } 364 }
365 } 365 }
366 366
367 -module.exports = S3;
...\ No newline at end of file ...\ No newline at end of file
367 +module.exports = S3;
......
...@@ -46,7 +46,11 @@ function file(curData){ ...@@ -46,7 +46,11 @@ function file(curData){
46 46
47 47
48 function uploadFile(fileData){ 48 function uploadFile(fileData){
49 - return axios.post('/api/file/upload', fileData); 49 + return axios.post('/api/file/upload', fileData, {
50 + headers :{
51 + 'Content-Type' : 'multipart/form-data'
52 + }
53 + });
50 } 54 }
51 55
52 function detailFile(fileData){ 56 function detailFile(fileData){
...@@ -58,21 +62,19 @@ function detailFile(fileData){ ...@@ -58,21 +62,19 @@ function detailFile(fileData){
58 }) 62 })
59 } 63 }
60 function deleteFile(fileData){ 64 function deleteFile(fileData){
61 - return axios.get('/api/file/delete', { 65 + return axios.get(`/api/file/delete/${fileData.fileName}`, {
62 params:{ 66 params:{
63 //현재 접속한 사람의 id와 삭제할 파일의 이름, 현재 폴더위치를 파라미터로 넘긴다. 67 //현재 접속한 사람의 id와 삭제할 파일의 이름, 현재 폴더위치를 파라미터로 넘긴다.
64 - id: fileData.id, 68 + id: fileData.user_id,
65 - name: fileData.fileName,
66 cur: fileData.cur 69 cur: fileData.cur
67 } 70 }
68 }); 71 });
69 } 72 }
70 function downloadFile(fileData){ 73 function downloadFile(fileData){
71 - return axios.get('api/file/download', { 74 + return axios.get(`api/file/download/${fileData.fileName}`, {
72 params:{ 75 params:{
73 //현재 접속한 사람의 id와 다운로드를 위해 선택한 파일의 이름을 파라미터로 넘긴다. 76 //현재 접속한 사람의 id와 다운로드를 위해 선택한 파일의 이름을 파라미터로 넘긴다.
74 id: fileData.id, 77 id: fileData.id,
75 - name: fileData.fileName,
76 cur: fileData.cur 78 cur: fileData.cur
77 } 79 }
78 }); 80 });
......
...@@ -94,18 +94,22 @@ ...@@ -94,18 +94,22 @@
94 <v-icon> mdi-file</v-icon> 94 <v-icon> mdi-file</v-icon>
95 </v-list-item-avatar> 95 </v-list-item-avatar>
96 <v-list-item-content> 96 <v-list-item-content>
97 - <v-list-item-title v-text="item"></v-list-item-title> 97 + <v-list-item-title v-text="item.file_name"></v-list-item-title>
98 </v-list-item-content> 98 </v-list-item-content>
99 <v-list-item-action> 99 <v-list-item-action>
100 - <v-btn icon> 100 + <v-btn icon @click="download_file(item.file_name)">
101 <v-icon color="grey lighten-1">mdi-information</v-icon> 101 <v-icon color="grey lighten-1">mdi-information</v-icon>
102 </v-btn> 102 </v-btn>
103 - <v-btn icon> 103 + <v-btn icon @click="delete_file(item.file_name)">
104 - <v-icon color="grey lighten-1">mdi-delted</v-icon> 104 + <v-icon color="grey lighten-1">mdi-deleted</v-icon>
105 </v-btn> 105 </v-btn>
106 </v-list-item-action> 106 </v-list-item-action>
107 </v-list-item> 107 </v-list-item>
108 </v-list> 108 </v-list>
109 + <input id = "file-selector" ref='uploadedfile' type="file"
110 + v-on:change="handleFileUpload()">
111 + <br>
112 + <!--
109 <v-file-input 113 <v-file-input
110 v-model="files" 114 v-model="files"
111 color="deep-purple accent-4" 115 color="deep-purple accent-4"
...@@ -136,6 +140,7 @@ ...@@ -136,6 +140,7 @@
136 </template> 140 </template>
137 141
138 </v-file-input> 142 </v-file-input>
143 +-->
139 <v-btn color="blue" @click = "upload_file">upload</v-btn> 144 <v-btn color="blue" @click = "upload_file">upload</v-btn>
140 <v-btn 145 <v-btn
141 bottom 146 bottom
...@@ -184,6 +189,7 @@ import Axios from 'axios'; ...@@ -184,6 +189,7 @@ import Axios from 'axios';
184 export default { 189 export default {
185 data() { 190 data() {
186 return { 191 return {
192 + uploadedfile:null,
187 foldername:'', 193 foldername:'',
188 curfName:'', 194 curfName:'',
189 folders: [], 195 folders: [],
...@@ -191,12 +197,18 @@ import Axios from 'axios'; ...@@ -191,12 +197,18 @@ import Axios from 'axios';
191 search:'', 197 search:'',
192 id: '', 198 id: '',
193 dialog:false, 199 dialog:false,
194 - search: '',
195 howMenu: false, 200 howMenu: false,
196 showMenu: false, 201 showMenu: false,
197 x: 0, 202 x: 0,
198 y: 0, 203 y: 0,
199 - dialog2:false 204 + dialog2:false,
205 + detail : {
206 + dataname: null,
207 + date: null,
208 + owner_id:null,
209 + datasize:null,
210 + datatype:null
211 + }
200 } 212 }
201 }, 213 },
202 async created(){ 214 async created(){
...@@ -207,21 +219,26 @@ import Axios from 'axios'; ...@@ -207,21 +219,26 @@ import Axios from 'axios';
207 } 219 }
208 console.log(curData); 220 console.log(curData);
209 const response = await folder(curData); 221 const response = await folder(curData);
210 - const {file_response} = await file(curData); 222 + const file_response = await file(curData);
211 - console.log(response.data);
212 - console.log(file_response);
213 this.$store.commit('setFolder', response.data.folders); 223 this.$store.commit('setFolder', response.data.folders);
214 this.$store.commit('setCur', response.data.cur); 224 this.$store.commit('setCur', response.data.cur);
215 this.$store.commit('setParent', response.data.parentPath); 225 this.$store.commit('setParent', response.data.parentPath);
216 this.folders = this.$store.getters.folderL; 226 this.folders = this.$store.getters.folderL;
217 this.$store.commit('setFile', file_response.data.files); 227 this.$store.commit('setFile', file_response.data.files);
228 + this.folders = this.$store.getters.folderL;
229 + console.log(this.$store.getters.fileL);
218 this.files = this.$store.getters.fileL; 230 this.files = this.$store.getters.fileL;
231 +
219 } catch (error) { 232 } catch (error) {
220 console.log("에러"); 233 console.log("에러");
221 - console.log(error.response.data); 234 + console.log(error);
222 } 235 }
223 }, 236 },
224 methods: { 237 methods: {
238 + handleFileUpload(){
239 + this.uploadedfile= this.$refs.uploadedfile.files[0]
240 + console.log(this.uploadedfile)
241 + },
225 initFolderName(){ 242 initFolderName(){
226 this.foldername = ''; 243 this.foldername = '';
227 }, 244 },
...@@ -325,28 +342,78 @@ import Axios from 'axios'; ...@@ -325,28 +342,78 @@ import Axios from 'axios';
325 }, 342 },
326 async upload_file(){ 343 async upload_file(){
327 try{ 344 try{
328 - const fileData={ 345 + const formData = new FormData();
329 - file: this.files, 346 + formData.append('file', this.uploadedfile);
330 - user_id: this.$store.state.id, 347 + formData.append('user_id', this.$store.state.id);
348 + formData.append('cur', this.$store.state.cur);
349 + const currentData={
350 + id: this.$store.state.id,
331 cur: this.$store.state.cur 351 cur: this.$store.state.cur
332 } 352 }
333 - console.log(fileData) 353 + console.log(currentData)
334 - const response = await uploadFile(fileData); 354 + const response = await uploadFile(formData);
335 - const filelist = await file(fileData.user_id); 355 + const filelist = await file(currentData);
336 - console.log(response.message); 356 + console.log(filelist.data.files);
337 this.$store.commit('setFile', filelist.data.files); 357 this.$store.commit('setFile', filelist.data.files);
338 - this.files = this.$store.getters.fileL; 358 + console.log(this.$store.getters.fileL);
359 + this.files = this.$store.getters.fileL;;
360 +
339 }catch(error){ 361 }catch(error){
340 - const fileData={ 362 + console.log("에러");
341 - file: this.files, 363 + console.log(error);
342 - user_id: this.$store.state.id, 364 + }
365 + },
366 + async delete_file(itemName){
367 + try{
368 + var itemlist = this.$store.getters.fileL;
369 + console.log(itemlist)
370 + console.log(itemName)
371 + const currentData={
372 + fileName : null,
373 + user_id: null,
343 cur: this.$store.state.cur 374 cur: this.$store.state.cur
344 } 375 }
345 - console.log(fileData); 376 +
377 + for(var i=0; i<itemlist.length; i++){
378 + console.log(itemlist[i].file_name)
379 + if(itemlist[i].file_name == itemName){
380 + currentData.fileName = itemlist[i].file_name;
381 + currentData.user_id = itemlist[i].user_id;
382 + }
383 + }
384 + const filelistData={
385 + id: currentData.user_id,
386 + cur: currentData.cur
387 + }
388 + console.log(currentData)
389 + const response = await deleteFile(currentData);
390 + setTimeout(function(){}, 500);
391 + const filelist = await file(filelistData);
392 + console.log(filelist.data.files);
393 + this.$store.commit('setFile', filelist.data.files);
394 + console.log(this.$store.getters.fileL);
395 + this.files = this.$store.getters.fileL;;
396 + }catch(error){
346 console.log("에러"); 397 console.log("에러");
347 - console.log(error.reponse.err); 398 + console.log(error);
348 } 399 }
349 }, 400 },
401 + async download_file(namedata){
402 + try{
403 + const currentData={
404 + fileName : namedata,
405 + id: this.$store.state.id,
406 + cur: this.$store.state.cur
407 + }
408 + const result = await downloadFile(currentData);
409 + console.log(result)
410 +
411 + }catch(error){
412 + console.log("에러");
413 + console.log(error);
414 + }
415 + }
416 + },
350 show (folderN, e) { 417 show (folderN, e) {
351 e.preventDefault() 418 e.preventDefault()
352 this.curfName = folderN; 419 this.curfName = folderN;
...@@ -357,6 +424,6 @@ import Axios from 'axios'; ...@@ -357,6 +424,6 @@ import Axios from 'axios';
357 this.showMenu = true 424 this.showMenu = true
358 }) 425 })
359 } 426 }
360 - } 427 +
361 } 428 }
362 </script> 429 </script>
......