feat: improve media handling

added local range requests, fix mime type detection, improve uploading using FormData, correctly use mime type allow list, added previews for audio, pdf and text
This commit is contained in:
dswbx
2025-09-29 14:55:19 +02:00
parent 0d74625270
commit 55082e9d0e
14 changed files with 255 additions and 26 deletions

View File

@@ -240,6 +240,8 @@ function EntityMediaFormField({
disabled?: boolean;
}) {
if (!entityId) return;
const maxLimit = 50;
const maxItems = field.getMaxItems();
const value = useStore(formApi.store, (state) => {
const val = state.values[field.name];
@@ -260,8 +262,9 @@ function EntityMediaFormField({
<FieldLabel field={field} />
<Media.Dropzone
key={key}
maxItems={field.getMaxItems()}
initialItems={value} /* @todo: test if better be omitted, so it fetches */
maxItems={maxItems}
allowedMimeTypes={field.getAllowedMimeTypes()}
/* initialItems={value} @todo: test if better be omitted, so it fetches */
onClick={onClick}
entity={{
name: entity.name,
@@ -270,6 +273,7 @@ function EntityMediaFormField({
}}
query={{
sort: "-id",
limit: maxItems && maxItems > maxLimit ? maxLimit : maxItems,
}}
/>
</Formy.Group>