Last active
March 2, 2023 23:45
-
-
Save lpil/841b81b67bd27361165253d075f39520 to your computer and use it in GitHub Desktop.
A file uploader + tagger written in under 20 lines and under 30 minutes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { serve } from "https://deno.land/[email protected]/http/server.ts"; | |
import { multiParser } from "https://deno.land/x/[email protected]/mod.ts"; | |
import * as uuid from "https://deno.land/[email protected]/uuid/mod.ts"; | |
import NodeID3 from "npm:node-id3"; | |
serve(async (req) => { | |
if (req.method == "POST") { | |
const { files, fields } = await multiParser(req); | |
const path = "uploads/" + uuid.v1.generate() + ".mp3"; | |
await Deno.writeFile(path, files.track.content); | |
NodeID3.update({ artist: fields.artist, title: fields.title }, path); | |
} | |
return new Response(await Deno.readTextFile("./index.html"), { | |
headers: { "Content-Type": "text/html; charset=utf-8" }, | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment