Request to Add Support for More File Types to the fileUpload Component
Closed this issue · 10 comments
The current fileUpload component only supports image uploads. If the component's functionality could be expanded to support a wider range of file types, such as xlsx, csv, etc., I would be very grateful.:)
I don't think that's the case, you should be able to specify your own file extensions of choice, just like how you do in html file inputs, if that doesn't work let me know and someone can work on fixing it.
Ah I see, there is an option to pass file extensions to the component but the actual extension is hard coded in the component
Working on this
I have tested the fix and will be trying to release it on the alpha channel soon. Now you can specify a format of your choice using the convention followed by react dropzone, more on that here : https://react-dropzone.org/#!/Accepting%20specific%20file%20types
This was my code:
const [htmlFile] = br.fileUpload({
accept: {
'text/html': ['.html', '.htm'],
},
label: 'Pick an HTML File',
});
if (htmlFile) {
br.write({ body: readFileSync(htmlFile.filepath).toString() });
}
@TL-SWFT I have released version 1.3.1-alpha.1 Please check and verify if it meets your expectations.
I've tested out the 1.3.1-alpha.1 release and it does meet my requirements. The fixes and updates you've included address the issues I was seeing with the previous version. It's works well for my use case.But there is one small issue that has not been modified, which is that the type of accept in fileUpload is not string but object. @sudo-vaibhav
That's expected since now file type is in accordance with react drop zone, which wants an object. I hope it's not too much of a problem to account for this in your code.
I have no other doubts, thank you for your reply.
fixed and merged