Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-CloudComputing
/
D_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
leeseohyeon
2020-06-07 23:07:18 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2095677aed86b91699192e60a337f213b19b4abd
2095677a
1 parent
005a7cca
빠른 액세스 수정
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
10 deletions
backend/routes/file/downloadFile.js
backend/routes/file/modifyFile.js
backend/routes/file/uploadFile.js
backend/routes/modules/awsconfig.json
backend/routes/quick.js
backend/routes/file/downloadFile.js
View file @
2095677
...
...
@@ -2,6 +2,7 @@ var express = require('express');
var
router
=
express
.
Router
();
var
fs
=
require
(
'fs'
);
var
moment
=
require
(
'moment'
);
var
AWS
=
require
(
'aws-sdk'
);
AWS
.
config
.
loadFromPath
(
__dirname
+
"/../modules/awsconfig.json"
);
...
...
@@ -19,7 +20,14 @@ router.get('/:name', function (req, res) {
S3
.
downloadFile3
(
S3
.
BUCKET_NAME
,
user_id
,
targetFile
,
function
(
result
,
downloadDir
)
{
if
(
result
)
{
res
.
send
({
src
:
downloadDir
})
var
sql
=
'UPDATE files SET recent_access=(?) WHERE user_id=(?) AND location=(?) AND file_name=(?)'
;
connection
.
query
(
sql
,
[
moment
().
format
(),
user_id
,
curPath
,
file_name
],
function
(
err
){
if
(
err
){
res
.
send
({
err
:
'update error'
});
}
else
{
res
.
send
({
src
:
downloadDir
})
}
})
}
else
{
res
.
send
({
err
:
'download error'
})
}
...
...
backend/routes/file/modifyFile.js
View file @
2095677
...
...
@@ -43,8 +43,8 @@ router.post('/:name', function(req, res){
S3
.
coverFile
(
S3
.
BUCKET_NAME
,
user_id
,
modified_name
,
targetPath
,
tempDownloadDir
,
function
(
result
)
{
if
(
result
)
{
var
sql
=
'UPDATE files SET file_name=(?), updated=(?) WHERE user_id=(?) AND location=(?) AND file_name=(?)'
;
connection
.
query
(
sql
,
[
modified_name
,
moment
().
format
(),
user_id
,
curPath
,
file_name
],
function
(
err
)
{
var
sql
=
'UPDATE files SET file_name=(?), updated=(?)
, recent_access=(?)
WHERE user_id=(?) AND location=(?) AND file_name=(?)'
;
connection
.
query
(
sql
,
[
modified_name
,
moment
().
format
(),
moment
().
format
(),
user_id
,
curPath
,
file_name
],
function
(
err
)
{
if
(
err
)
{
console
.
log
(
err
);
res
.
send
({
error
:
'update error'
});
...
...
backend/routes/file/uploadFile.js
View file @
2095677
...
...
@@ -2,6 +2,7 @@ var express = require('express');
var
router
=
express
.
Router
();
var
formidable
=
require
(
'formidable'
);
var
moment
=
require
(
'moment'
);
var
AWS
=
require
(
'aws-sdk'
);
AWS
.
config
.
loadFromPath
(
__dirname
+
"/../modules/awsconfig.json"
);
...
...
@@ -66,8 +67,8 @@ router.post('/', function (req, res) {
}
}
for
(
var
sourceFile
of
noErrSourceFiles
)
{
var
sql
=
'INSERT INTO files (file_name, user_id, location
) VALUES (
?, ?, ?)'
;
connection
.
query
(
sql
,
[
sourceFile
,
user_id
,
curPath
],
function
(
err
,
result
)
{
var
sql
=
'INSERT INTO files (file_name, user_id, location
, recent_access) VALUES (?,
?, ?, ?)'
;
connection
.
query
(
sql
,
[
sourceFile
,
user_id
,
curPath
,
moment
().
format
()
],
function
(
err
,
result
)
{
if
(
err
)
{
console
.
log
(
'insert error'
);
res
.
send
({
error
:
'insert error'
});
...
...
backend/routes/modules/awsconfig.json
View file @
2095677
{
"accessKeyId"
:
"ASIA
XZL2SWFEYG2GUYV
J"
,
"secretAccessKey"
:
"
ceYvfLs25iiBDfigO7PbP67kJoKswJdfduqROrJt
"
,
"sessionToken"
:
"FwoGZXIvYXdzE
DMaDGvezwF9kQrAJ+uhfSLDASWFKBk7UNbRzZVEM1eoGJ3E+UI9d4xSpqEDqRYjsOTn5wYIGM3mUCZ8S6/XCnGP5yFz+qv9mBLDf311iP9ajY091OhQ8c2nB6l+JHuRKAz6FhGLrjHtD1AecHtjHOu5dXODU2+9ctvGj7V60KYqjToah5Tvv84EVac/41Les3rtrqcXS/bbmVwv5kDz9K1FJStln4sXZ/foueGHZAkAJQ6LAtIQWg4/reFUcWAi8E0bUjMckmymDQhnVNWcSbgQ+htBYiiPg+P2BTItOqWuZojM5lw32rTv7+PuOaeyHjx3+Vcd4bo3orSJr57P2ZPfmglZNKY7W5aw
"
,
"accessKeyId"
:
"ASIA
ZQ5XTMMFYKGWGIQ
J"
,
"secretAccessKey"
:
"
d3ljiFkZ9QhRxCwE99mw3oFMaVa3JRPkMFDKec48
"
,
"sessionToken"
:
"FwoGZXIvYXdzE
H8aDHT83Ci5/yuYOOCJTyLDAaQaZLTrJaQf7IsZGhY0UEqpHWgOp7j9T+d/WIpoCxVD/GP53RMlVHlFMfCerfkWEVNXWJOkblExYDBTt4QMLzdhONlOQWVONAvhL8agZ6bUS66sHMQ+PlG+CO/Fjj1pLzOXc2g20elUC0+45pdczi8o33UJEACOCW11K5tYzE2lqjrdggOU00VICLNU5HmPYGH/Sku6NG3goo3hKwrCY2m/YhuPB0hP29g/dLpaUum2oy2VXryi1K255d5tontTA8Dbcyj13PP2BTIt5eqJvxyyyNzJCrXfK1LZkA8WCEMbGTasgfkwm5m7yBKrVFMpEdy9gvcXzuva
"
,
"region"
:
"us-east-1"
}
...
...
backend/routes/quick.js
View file @
2095677
...
...
@@ -5,11 +5,11 @@ var router = express.Router();
router
.
get
(
'/'
,
function
(
req
,
res
){
var
user_id
=
req
.
query
.
id
;
var
sql
=
'SELECT * FROM files WHERE
updated>date_sub(now(), interval 3 day) AND user_id=(?) ORDER BY updated DESC
'
;
var
sql
=
'SELECT * FROM files WHERE
recent_access>date_sub(now(), interval 3 day) AND user_id=(?)
'
;
connection
.
query
(
sql
,
user_id
,
function
(
err
,
result
){
if
(
err
){
console
.
log
(
'select error'
);
res
.
send
({
error
:
'quick error'
})
res
.
send
({
error
:
'quick error'
})
;
}
else
{
res
.
send
(
result
);
}
...
...
Please
register
or
login
to post a comment