finished metrics
This commit is contained in:
parent
76a6f02eb7
commit
99477774cf
9 changed files with 542 additions and 173 deletions
|
@ -107,12 +107,18 @@ app.get('/download/:id', (req, res) => {
|
|||
storage
|
||||
.length(id)
|
||||
.then(contentLength => {
|
||||
res.render('download', {
|
||||
filename: decodeURIComponent(filename),
|
||||
filesize: bytes(contentLength),
|
||||
trackerId: conf.analytics_id,
|
||||
dsn: conf.sentry_id
|
||||
});
|
||||
storage
|
||||
.ttl(id)
|
||||
.then(timeToExpiry => {
|
||||
res.render('download', {
|
||||
filename: decodeURIComponent(filename),
|
||||
filesize: bytes(contentLength),
|
||||
sizeInBytes: contentLength,
|
||||
timeToExpiry: timeToExpiry,
|
||||
trackerId: conf.analytics_id,
|
||||
dsn: conf.sentry_id
|
||||
});
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
res.render('download');
|
||||
|
|
|
@ -23,6 +23,7 @@ if (conf.s3_bucket) {
|
|||
module.exports = {
|
||||
filename: filename,
|
||||
exists: exists,
|
||||
ttl: ttl,
|
||||
length: awsLength,
|
||||
get: awsGet,
|
||||
set: awsSet,
|
||||
|
@ -39,6 +40,7 @@ if (conf.s3_bucket) {
|
|||
module.exports = {
|
||||
filename: filename,
|
||||
exists: exists,
|
||||
ttl: ttl,
|
||||
length: localLength,
|
||||
get: localGet,
|
||||
set: localSet,
|
||||
|
@ -73,6 +75,18 @@ function metadata(id) {
|
|||
});
|
||||
}
|
||||
|
||||
function ttl(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
redis_client.ttl(id, (err, reply) => {
|
||||
if (!err) {
|
||||
resolve(reply * 1000);
|
||||
} else {
|
||||
reject(err);
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function filename(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
redis_client.hget(id, 'filename', (err, reply) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue