remove example

This commit is contained in:
srgooglo 2022-01-10 11:59:02 +01:00
parent aa8fbe2a12
commit c890511d77
3 changed files with 0 additions and 72 deletions

View File

@ -1,48 +0,0 @@
const { Storage } = require('@ragestudio/cloudlink/dist/classes')
const path = require('path')
const { performance } = require('perf_hooks')
// TODO: Access token, permission object type
const handler = new Storage({ driver: "fs", root: path.resolve(process.cwd(), "uploads") })
module.exports = {
set: (req, res, next) => {
const { files } = req
if (typeof files.file !== "undefined") {
let file = files.file
file.name = `${file.md5}_${file.name}`
const timeBefore = performance.now()
handler.setSync(file, undefined)
.then((stat) => {
const tooks = (performance.now() - timeBefore).toFixed(2)
return res.json({
tooks: `~${tooks}ms`,
filename: file.name,
mimetype: file.mimetype,
encoding: file.encoding,
size: stat.size
})
})
}
},
get: (req, res, next) => {
const { query } = req
if (typeof query.file === "undefined") {
res.status(404)
return res.json({ error: "Not provided filename" })
}
handler.getSync(query.file)
.then((data) => {
res.write(data.buffer, 'binary')
res.end(null, 'binary')
})
.catch((error) => {
res.status(404)
res.json({ error: error.message })
})
}
}

View File

@ -1,14 +0,0 @@
[
{
"method": "PUT",
"route": "/upload",
"controller": "filecontroller",
"fn": "set"
},
{
"method": "GET",
"route": "/resources",
"controller": "filecontroller",
"fn": "get"
}
]

View File

@ -1,10 +0,0 @@
{
"name": "uploadServer",
"version": "0.1.0",
"scripts": {
"start": "linebridge"
},
"dependencies": {
"linebridge": "^0.7.0"
}
}