upd: dashboard admin

Deskripsi
- edit upload ttd setting desa

No Issues
This commit is contained in:
2025-11-20 16:09:36 +08:00
parent 03715b7c98
commit d0ff675950
5 changed files with 96 additions and 25 deletions

View File

@@ -0,0 +1,12 @@
import { v4 as uuidv4 } from "uuid";
import { mimeToExtension } from "./mimetypeToExtension";
export function renameFile({ oldFile, newName }: { oldFile: File; newName: string }) {
const ext = mimeToExtension(oldFile.type)
const nameFix = newName == 'random' ? `${uuidv4()}.${ext}` : newName
return new File([oldFile], nameFix, {
type: oldFile.type,
lastModified: oldFile.lastModified,
});
}

View File

@@ -159,7 +159,7 @@ export async function uploadFile(config: Config, file: File): Promise<string> {
const text = await res.text();
if (!res.ok) throw new Error(`Upload failed: ${text}`);
if (!res.ok) return 'gagal'
return `✅ Uploaded ${file.name} successfully`;
}