diff --git a/database.sqlite3 b/database.sqlite3 index 23c1a34..9fadc38 100644 Binary files a/database.sqlite3 and b/database.sqlite3 differ diff --git a/index.js b/index.js index bf0a67b..23358c4 100644 --- a/index.js +++ b/index.js @@ -181,6 +181,9 @@ app.get("/api/logout", authorized(), (req, res) => { app.post("/api/upload-video", authorized(), fileUpload({ limits: { fileSize: 2 ** 26 }, useTempFiles: true }), async (req, res) => { const { title } = req.body; + if (!title) { + return res.status(400).json({ ok: false, error: "bad request" }); + } if (!req.files || !req.files.video) { return res.status(400).json({ ok: false, error: "bad request" }); @@ -206,6 +209,7 @@ app.post("/api/upload-video", authorized(), fileUpload({ limits: { fileSize: 2 * const queueItem = { videoId: id, userId, + title, errors: [], progress: 0, duration, diff --git a/public/queue/script.js b/public/queue/script.js index de0f090..7882a2e 100644 --- a/public/queue/script.js +++ b/public/queue/script.js @@ -36,11 +36,11 @@ async function main() {
  • - - + +
    - ${vid.title} + ${vid.title}

    Uploaded ${uploadedTime} of ${totalTime} (${percentage}%)

    ${percentage}% diff --git a/public/upload/index.html b/public/upload/index.html index 4f24573..9a264cb 100644 --- a/public/upload/index.html +++ b/public/upload/index.html @@ -4,19 +4,21 @@ MaoTube + +

    MaoTube

    -
    - - - - -
    -
    + + + + + +

    +

    + View upload queue
    - diff --git a/public/upload/script.js b/public/upload/script.js new file mode 100644 index 0000000..30436ea --- /dev/null +++ b/public/upload/script.js @@ -0,0 +1,14 @@ +document.getElementById("upload-form").addEventListener("submit", async event => { + event.preventDefault(); + + const data = new FormData(event.target); + console.log(data); + + await fetch("/api/upload-video", { + method: "POST", + body: data, + }); + + + location.href = "/queue"; +});