import { extname } from "https://deno.land/std@0.128.0/path/mod.ts"; const dirPath = "/"; const watcher = Deno.watchFs(dirPath); try { for await (const event of watcher) { if (event.kind !== "create" && event.kind !== "modify") continue; for (const path of event.paths) { if (![".png", ".jpg", ".jpeg", ".gif"].includes( extname(path).toLowerCase() )) continue; const data = await Deno.readFile(path); await upload(data); } } } finally { watcher.close(); }