Kinto / kinto-admin

Kinto Web Administration Console
http://kinto.github.io/kinto-admin/
183 stars 35 forks source link

Add a new widget to store arbitrary files as base64 using a file input #3263

Open leplatrem opened 3 weeks ago

leplatrem commented 3 weeks ago

This would allow users to store relatively small files as attributes on records instead of using attachments.

Typical use-case is to store the thumbnail of the file that is attached on the record.

In order to do this, we will need:

The record schema would be:

properties:
  thumbnail:
    type: string

And the collection UI schema:

uiSchema:
  thumbnail:
    ui:widget: base64input

Then instead of contributing a new widget in the rjsf upstream project, we can follow the pattern that we currently have for our local JSON editor, and inject it ourselves during form instantiation:

https://github.com/Kinto/kinto-admin/blob/349a3748553324cd1ee14cf2a110895e68c189f7/src/components/JSONEditor.tsx#L12-L33

https://github.com/Kinto/kinto-admin/blob/349a3748553324cd1ee14cf2a110895e68c189f7/src/components/group/GroupForm.tsx#L44-L48

In this case we would replace occurrences of base64input by instances of our base64 widget.

See also:

nathan-barrett commented 3 weeks ago

Thanks @leplatrem - feel free to assign me and I'll take a stab at it