leeseohyeon

빠른 액세스 수정

......@@ -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) {
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'})
}
......
......@@ -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' });
......
......@@ -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'});
......
{
"accessKeyId": "ASIAXZL2SWFEYG2GUYVJ",
"secretAccessKey": "ceYvfLs25iiBDfigO7PbP67kJoKswJdfduqROrJt",
"sessionToken": "FwoGZXIvYXdzEDMaDGvezwF9kQrAJ+uhfSLDASWFKBk7UNbRzZVEM1eoGJ3E+UI9d4xSpqEDqRYjsOTn5wYIGM3mUCZ8S6/XCnGP5yFz+qv9mBLDf311iP9ajY091OhQ8c2nB6l+JHuRKAz6FhGLrjHtD1AecHtjHOu5dXODU2+9ctvGj7V60KYqjToah5Tvv84EVac/41Les3rtrqcXS/bbmVwv5kDz9K1FJStln4sXZ/foueGHZAkAJQ6LAtIQWg4/reFUcWAi8E0bUjMckmymDQhnVNWcSbgQ+htBYiiPg+P2BTItOqWuZojM5lw32rTv7+PuOaeyHjx3+Vcd4bo3orSJr57P2ZPfmglZNKY7W5aw",
"accessKeyId": "ASIAZQ5XTMMFYKGWGIQJ",
"secretAccessKey": "d3ljiFkZ9QhRxCwE99mw3oFMaVa3JRPkMFDKec48",
"sessionToken": "FwoGZXIvYXdzEH8aDHT83Ci5/yuYOOCJTyLDAaQaZLTrJaQf7IsZGhY0UEqpHWgOp7j9T+d/WIpoCxVD/GP53RMlVHlFMfCerfkWEVNXWJOkblExYDBTt4QMLzdhONlOQWVONAvhL8agZ6bUS66sHMQ+PlG+CO/Fjj1pLzOXc2g20elUC0+45pdczi8o33UJEACOCW11K5tYzE2lqjrdggOU00VICLNU5HmPYGH/Sku6NG3goo3hKwrCY2m/YhuPB0hP29g/dLpaUum2oy2VXryi1K255d5tontTA8Dbcyj13PP2BTIt5eqJvxyyyNzJCrXfK1LZkA8WCEMbGTasgfkwm5m7yBKrVFMpEdy9gvcXzuva",
"region": "us-east-1"
}
......
......@@ -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);
}
......