From 20da6f30202620cce129632a3d0328bce2a38e67 Mon Sep 17 00:00:00 2001 From: stringsplit <77242831+nbitzz@users.noreply.github.com> Date: Mon, 26 Dec 2022 21:13:55 -0800 Subject: [PATCH] 1.1.1 --- package.json | 2 +- pages/clone.html | 134 ++++++++++++++++++++++++++++++++++++++++++++++ pages/upload.html | 4 +- src/index.ts | 9 +++- 4 files changed, 145 insertions(+), 4 deletions(-) create mode 100644 pages/clone.html diff --git a/package.json b/package.json index 5b240c3..652ff0d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "monofile", - "version": "1.1.0", + "version": "1.1.1", "description": "", "main": "index.js", "scripts": { diff --git a/pages/clone.html b/pages/clone.html new file mode 100644 index 0000000..d5e209f --- /dev/null +++ b/pages/clone.html @@ -0,0 +1,134 @@ + + + + + + + monofile + + + + + + + + +
+

+ monofile +

+

Discord-based file sharing

+
+ Before sharing files, please remember: + +
+
+
+

+ Max filesize on instance: $MaxInstanceFilesize +

+

made by nbitzz — githubupload a file...

+
+
+ + + + + \ No newline at end of file diff --git a/pages/upload.html b/pages/upload.html index e544126..6a4ea88 100644 --- a/pages/upload.html +++ b/pages/upload.html @@ -95,7 +95,7 @@

Max filesize on instance: $MaxInstanceFilesize

-

made by nbitzz — github

+

made by nbitzz — githubclone from url...

@@ -124,7 +124,7 @@ xmlhttp.addEventListener("load",function() { if (xmlhttp.status == 200) { document.getElementById("CopyTB").value = `https://${location.hostname}/download/${xmlhttp.responseText}` - updateBtnTxt(`Upload complete.
Copy URL View URL`) + updateBtnTxt(`Upload complete.
Copy URL View URL`) } else { updateBtnTxt(`Upload failed.
${xmlhttp.responseText}`) } diff --git a/src/index.ts b/src/index.ts index ffb58f4..5932ea9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -107,6 +107,13 @@ app.get("/", function(req,res) { }) }) +app.get("/clone", function(req,res) { + fs.readFile(__dirname+"/../pages/clone.html",(err,buf) => { + if (err) {res.sendStatus(500);console.log(err);return} + res.send(buf.toString().replace("$MaxInstanceFilesize",`${(config.maxDiscordFileSize*config.maxDiscordFiles)/1048576}MB`)) + }) +}) + app.post("/upload",multerSetup.single('file'),async (req,res) => { if (req.file) { uploadFile({name:req.file.originalname,mime:req.file.mimetype},req.file.buffer) @@ -120,7 +127,7 @@ app.post("/upload",multerSetup.single('file'),async (req,res) => { app.post("/clone",(req,res) => { axios.get(req.body,{responseType:"blob"}).then((data:AxiosResponse) => { - uploadFile({name:req.body.split("/")[req.body.split("/").length],mime:data.headers["content-type"]},Buffer.from(data.data)) + uploadFile({name:req.body.split("/")[req.body.split("/").length] || "generic",mime:data.headers["content-type"]},Buffer.from(data.data)) .then((uID) => res.send(uID)) .catch((stat) => {res.status(stat.status);res.send(`[err] ${stat.message}`)}) }).catch((err) => {