Nightly: Drag & Drop Upload im Header (Admin) + Server-Upload-Endpoint (/api/upload, MP3/WAV)
This commit is contained in:
parent
c1f4d0f3a0
commit
9e7b572feb
3 changed files with 60 additions and 2 deletions
|
|
@ -184,6 +184,22 @@ export async function playUrl(url: string, guildId: string, channelId: string, v
|
|||
}
|
||||
}
|
||||
|
||||
export async function uploadFile(file: File, folder?: string) {
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
if (folder) form.append('folder', folder);
|
||||
const res = await fetch(`${API_BASE}/upload`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
body: form
|
||||
});
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(()=>({}));
|
||||
throw new Error(data?.error || 'Upload failed');
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue