박기범

Download testing

{
"accessKeyId": "ASIAZQ5XTMMF77IHPTR6",
"secretAccessKey": "IIDj5U3n6603WcAOf2OMTj2V6urKuGQaRGXABtVd",
"sessionToken": "FwoGZXIvYXdzENH//////////wEaDLvwZHLSr6GbUZyD0yLDAVKxxzxNeyC41xtvOmvV9Xmeor5N/Uy6byi1/D/9K6OoGSwdgPNlyyz5EzCsB3UDWtyWGSmIX9PreX0FX2wnD5/VHDl9QibRMUpXOBlg95BNHrfx0e7Srfn6a1GY8eN9ntiqiv7DuS3jV7I7L9NOE218dxDnt4hul8gStVZ4urSXlz4KUAXLucCbF4y2c/KuDVqKPM/9+MQgnL6f3bHThwNEhZhm4CjyHQYZgB2eGd9HYi95RYC9NglBi1gH60Iao8AELSi8wc32BTItNSdy9ymXld6zjj9OnqNzUZdm+GdCX8qFQ87nzVzmX7kHEOWnK9x+4zTHbGXx",
"accessKeyId": "ASIAXZL2SWFE22KE6FMR",
"secretAccessKey": "xicAWumxI045y2H/gpvHj931ejPAxKx05z3s7306",
"sessionToken": "FwoGZXIvYXdzENT//////////wEaDMjAgd73D8cgPHM6cCLDARgKnP64irW5N1G56jblgQgjgf58Xwfr/Ysghx6udQ0sS5St5XOtnc/nMqukHOc//gqPaSgNZza57fmaIQVdTM8dgSbM6a72SbXirYO38YDfzHCQz73gg2DWAjrZy2RDu1v8lmshh3393B9MuZFEEJzDgsLgNAmQmP5iULRVqnVqRhUcuhMxFz91nsSuts1u0r41sBZTEwKjE3Qnor3PrUS7KKeZqi8axod4jEwLCDj+CW6N2l5I8QeXtanrKnHGVL4NiiiJlc72BTIt1pHEnchZvLii96Afs5ThV/018vTKHgqZl7m/QGHCVc5hwcNOU6MLnwSLHFYf",
"region": "us-east-1"
}
\ No newline at end of file
}
......
......@@ -17,7 +17,7 @@
var AWS = require('aws-sdk');
AWS.config.update({ region: 'ap-northeast-2' });
var BUCKET_NAME = 'dkhuloud';
var BUCKET_NAME = 'qkrrlqja-test';
var s3 = new AWS.S3();
var fs = require('fs');
......@@ -230,7 +230,7 @@ var S3 = {
sourceFile = sourceFile.split('(')[0] + '(' + lvNum.toString() + ')' + sourceFile.split(')')[1];
}
console.log('makeVersion ', sourceFile);
callback(true, sourceFile);
},
......@@ -348,7 +348,7 @@ var S3 = {
var makeFolder = function(dir, callback){
var paths = dir.substring(__dirname.length+1); // download/userId/folder1/folder2/test.txt
paths = paths.split('/');
var folders = __dirname;
for(var i=0; i<paths.length-1; i++){
folders += '/'+paths[i];
......@@ -364,4 +364,4 @@ var makeFolder = function(dir, callback){
}
}
module.exports = S3;
\ No newline at end of file
module.exports = S3;
......
......@@ -46,7 +46,11 @@ function file(curData){
function uploadFile(fileData){
return axios.post('/api/file/upload', fileData);
return axios.post('/api/file/upload', fileData, {
headers :{
'Content-Type' : 'multipart/form-data'
}
});
}
function detailFile(fileData){
......@@ -58,21 +62,19 @@ function detailFile(fileData){
})
}
function deleteFile(fileData){
return axios.get('/api/file/delete', {
return axios.get(`/api/file/delete/${fileData.fileName}`, {
params:{
//현재 접속한 사람의 id와 삭제할 파일의 이름, 현재 폴더위치를 파라미터로 넘긴다.
id: fileData.id,
name: fileData.fileName,
id: fileData.user_id,
cur: fileData.cur
}
});
}
function downloadFile(fileData){
return axios.get('api/file/download', {
return axios.get(`api/file/download/${fileData.fileName}`, {
params:{
//현재 접속한 사람의 id와 다운로드를 위해 선택한 파일의 이름을 파라미터로 넘긴다.
id: fileData.id,
name: fileData.fileName,
cur: fileData.cur
}
});
......
......@@ -94,18 +94,22 @@
<v-icon> mdi-file</v-icon>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title v-text="item"></v-list-item-title>
<v-list-item-title v-text="item.file_name"></v-list-item-title>
</v-list-item-content>
<v-list-item-action>
<v-btn icon>
<v-btn icon @click="download_file(item.file_name)">
<v-icon color="grey lighten-1">mdi-information</v-icon>
</v-btn>
<v-btn icon>
<v-icon color="grey lighten-1">mdi-delted</v-icon>
<v-btn icon @click="delete_file(item.file_name)">
<v-icon color="grey lighten-1">mdi-deleted</v-icon>
</v-btn>
</v-list-item-action>
</v-list-item>
</v-list>
<input id = "file-selector" ref='uploadedfile' type="file"
v-on:change="handleFileUpload()">
<br>
<!--
<v-file-input
v-model="files"
color="deep-purple accent-4"
......@@ -136,6 +140,7 @@
</template>
</v-file-input>
-->
<v-btn color="blue" @click = "upload_file">upload</v-btn>
<v-btn
bottom
......@@ -184,6 +189,7 @@ import Axios from 'axios';
export default {
data() {
return {
uploadedfile:null,
foldername:'',
curfName:'',
folders: [],
......@@ -191,12 +197,18 @@ import Axios from 'axios';
search:'',
id: '',
dialog:false,
search: '',
howMenu: false,
showMenu: false,
x: 0,
y: 0,
dialog2:false
dialog2:false,
detail : {
dataname: null,
date: null,
owner_id:null,
datasize:null,
datatype:null
}
}
},
async created(){
......@@ -207,21 +219,26 @@ import Axios from 'axios';
}
console.log(curData);
const response = await folder(curData);
const {file_response} = await file(curData);
console.log(response.data);
console.log(file_response);
const file_response = await file(curData);
this.$store.commit('setFolder', response.data.folders);
this.$store.commit('setCur', response.data.cur);
this.$store.commit('setParent', response.data.parentPath);
this.folders = this.$store.getters.folderL;
this.$store.commit('setFile', file_response.data.files);
this.folders = this.$store.getters.folderL;
console.log(this.$store.getters.fileL);
this.files = this.$store.getters.fileL;
} catch (error) {
console.log("에러");
console.log(error.response.data);
console.log(error);
}
},
methods: {
handleFileUpload(){
this.uploadedfile= this.$refs.uploadedfile.files[0]
console.log(this.uploadedfile)
},
initFolderName(){
this.foldername = '';
},
......@@ -325,28 +342,78 @@ import Axios from 'axios';
},
async upload_file(){
try{
const fileData={
file: this.files,
user_id: this.$store.state.id,
const formData = new FormData();
formData.append('file', this.uploadedfile);
formData.append('user_id', this.$store.state.id);
formData.append('cur', this.$store.state.cur);
const currentData={
id: this.$store.state.id,
cur: this.$store.state.cur
}
console.log(fileData)
const response = await uploadFile(fileData);
const filelist = await file(fileData.user_id);
console.log(response.message);
console.log(currentData)
const response = await uploadFile(formData);
const filelist = await file(currentData);
console.log(filelist.data.files);
this.$store.commit('setFile', filelist.data.files);
this.files = this.$store.getters.fileL;
console.log(this.$store.getters.fileL);
this.files = this.$store.getters.fileL;;
}catch(error){
const fileData={
file: this.files,
user_id: this.$store.state.id,
console.log("에러");
console.log(error);
}
},
async delete_file(itemName){
try{
var itemlist = this.$store.getters.fileL;
console.log(itemlist)
console.log(itemName)
const currentData={
fileName : null,
user_id: null,
cur: this.$store.state.cur
}
console.log(fileData);
for(var i=0; i<itemlist.length; i++){
console.log(itemlist[i].file_name)
if(itemlist[i].file_name == itemName){
currentData.fileName = itemlist[i].file_name;
currentData.user_id = itemlist[i].user_id;
}
}
const filelistData={
id: currentData.user_id,
cur: currentData.cur
}
console.log(currentData)
const response = await deleteFile(currentData);
setTimeout(function(){}, 500);
const filelist = await file(filelistData);
console.log(filelist.data.files);
this.$store.commit('setFile', filelist.data.files);
console.log(this.$store.getters.fileL);
this.files = this.$store.getters.fileL;;
}catch(error){
console.log("에러");
console.log(error.reponse.err);
console.log(error);
}
},
async download_file(namedata){
try{
const currentData={
fileName : namedata,
id: this.$store.state.id,
cur: this.$store.state.cur
}
const result = await downloadFile(currentData);
console.log(result)
}catch(error){
console.log("에러");
console.log(error);
}
}
},
show (folderN, e) {
e.preventDefault()
this.curfName = folderN;
......@@ -357,6 +424,6 @@ import Axios from 'axios';
this.showMenu = true
})
}
}
}
</script>
......