Handling File Upload – API platform — How to use

I’ve read and test this tutorial
for uploading image with api platform and vich in symfony

https://api-platform.com/docs/core/file-upload/#handling-file-upload

but i don’t understand how to use it really in my app

I use react-admin and i want use the field (dropzone)

any ideas to find a complete tutorial ?

for uploading in react-admin like this technique

Thank’s a lot
O.M

this is the edit form in react-admin

import React from "react";
import {
  HydraAdmin, ResourceGuesser, EditGuesser,
  InputGuesser
} from "@api-platform/admin";
import { ImageInput, ImageField } from 'react-admin';
import CategoryIcon from '@material-ui/icons/Class';
import Layout from './Custom/Layout';
import polyglotI18nProvider from 'ra-i18n-polyglot';
import frenchMessages from 'ra-language-french';

const i18nProvider = polyglotI18nProvider(() => frenchMessages, 'fr');


// 

const CategoryEdit = props => (
  <EditGuesser {...props}>
    <InputGuesser source="name" label="Nom de la catégorie" />

    <ImageInput source="image" label="Image de la catégorie" accept="image/*" placeholder={<p>Glisser votre image ici</p>}>
      <ImageField source="src" title="title" />
    </ImageInput>
  </EditGuesser>
);
export default () => (
  <HydraAdmin i18nProvider={i18nProvider} layout={Layout} entrypoint="https://localhost:8000/api">
    <ResourceGuesser name="categories" edit={CategoryEdit} icon={CategoryIcon} options={{ label: "Catégories d'objets" }} />
    <ResourceGuesser name="ad_objects" options={{ label: "Annonces" }} />
  </HydraAdmin>
);

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *