fix image upload
visual improvements
This commit is contained in:
parent
94c1e0b679
commit
fe5d77443d
7 changed files with 134 additions and 24 deletions
|
|
@ -28,9 +28,10 @@ export async function uploadMedia(file: File) {
|
|||
formData.append('file', file);
|
||||
formData.append('alt', file.name.replace(/\.[^/.]+$/, '').replace(/[-_]/g, ' '));
|
||||
|
||||
const record = await pb.collection('media').create(formData);
|
||||
return {
|
||||
record,
|
||||
url: getFileUrl(record.collectionId, record.id, record.file)
|
||||
};
|
||||
const res = await fetch('/admin/api/upload', { method: 'POST', body: formData });
|
||||
if (!res.ok) {
|
||||
const err = await res.json().catch(() => ({}));
|
||||
throw new Error(err?.message || `Upload failed (${res.status})`);
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue