pr changes
This commit is contained in:
parent
4968e501e1
commit
bb5e05319a
1 changed files with 19 additions and 23 deletions
14
app.js
14
app.js
|
@ -72,18 +72,14 @@ app.post("/upload/:id", function (req, res, next) {
|
|||
file.pipe(fstream);
|
||||
fstream.on("close", function () {
|
||||
let id = req.params.id;
|
||||
let uuid = Math.floor(Math.random() * 10000000).toString()
|
||||
+ Math.floor(Math.random() * 10000000).toString()
|
||||
+ Math.floor(Math.random() * 10000000).toString();
|
||||
let uuid = crypto.randomBytes(10).toString('hex');
|
||||
|
||||
client.hset(id, "filename", filename);
|
||||
client.hset(id, "expiration", 0);
|
||||
client.hset(id, "delete", uuid);
|
||||
client.hmset([id, "filename", filename, "delete", uuid]);
|
||||
|
||||
// delete the file off the server in 24 hours
|
||||
setTimeout(function() {
|
||||
fs.unlinkSync(__dirname + "/static/" + id);
|
||||
}, 86400000);
|
||||
// setTimeout(function() {
|
||||
// fs.unlinkSync(__dirname + "/static/" + id);
|
||||
// }, 86400000);
|
||||
|
||||
client.expire(id, 86400000);
|
||||
console.log("Upload Finished of " + filename);
|
||||
|
|
Loading…
Reference in a new issue