m-inan / react-upload-gallery

React for Upload Image Gallery. Sorted by drag & drop and Customizable
MIT License
78 stars 44 forks source link

Custom Fields inside image state data #29

Closed modbender closed 3 years ago

modbender commented 3 years ago

I'm using Django Rest API for image upload/delete or any modification. The problem is that I need extra fields such as ID for the database object created for the uploaded image to be accessible from onDeleted to be able to delete it using the backend API.

I would also like it if I'm able to save additional fields inside state image data.

modbender commented 3 years ago

Ok I just checked the source code, and seen that onSuccess does have a append field. But for cases where customRequest is not defined, it's best to have something similar to source that helps define extra fields.

m-inan commented 3 years ago

Maybe object data created using response with a prop called aliases can be added to the image object.

<RUG
  ...
  alias={(response) => ({
    slug: response.slug
  })}
/>
modbender commented 3 years ago

That's a good idea.