Description
What problem does this feature solve?
Currently the six-file-upload
component exposes an event six-file-upload-success
, that returns a CustomEvent of type SixFileUploadSuccessPayload
. This is a union type of IMultipleFiles | ISingleFile
(these types are not exported), where the former has a property called files
and the latter a property called file
, depending on whether the multiple
flag is set.
When using the six-file-upload
component, it is difficult to access these properties/events in a type safe manner.
What does the proposed API look like?
My suggestion would be to get rid of IMultipleFiles
and ISingleFile
and change the interface of SixFileUploadSuccessPayload
to be the following:
export interface SixFileUploadSuccessPayload {
files: FileList;
}
The event six-file-upload-success
should always return an array of files in its event payload. If the component has the property multiple
set to false, there will only be one file in the array.
If the change would be implemented like this, this would be a breaking change and we would have to think about adding an additional event and deprecate the current one, or something similar to this.
Additional one could argue, that we could combine the success/failure event (not sure what is the best practice here) and expose just one event which contains a failure/success response and/or the uploaded files. This would force the user to actually handle the failure case. Currently the user is not required to handle the failure case.