Custom Renderer for Upload Function

How to define new type for file upload and while creating uiSchema. It would be great if any of the user here have implemented. Should we use type as control too?

Hi @roshan-budhathoki,

In case the file upload is represented in the JSON Schema in some way then you don’t need any new UI Schema type. Then you just need a custom renderer and a corresponding tester which analyses the schema for the elements for which a file upload shall be shown.

If it’s unrelated to the schema and only specified in the UI Schema then you could go either way. Using an own type, e.g. type: 'FileUpload' is the most explicit way of defining it and makes the most sense if the FileUpload is incompatible with the existing types, e.g. because it doesn’t have a scope refering to some part of the JSON Schema.
If the file upload is just a special control then you could keep using Control and just add a special marker for your tester, e.g. by adding a variant: 'FileUpload' attribute to the control. If you ever have a case of sharing UI Schemas with someone who doesn’t have the file upload custom renderer, then at least some basic input is shown for them.
Very likely it doesn’t really matter which of these two UI Schema approaches (custom type or additional attribute) are used.

1 Like