react-widget
react-widget copied to clipboard
Array of FileInfo objects back onSuccess of fileGroup upload
Currently, what's returned when uploading multiple files isn't actually a fileInfo object. Instead, what's returned is a truncated object sort of based on what would be returned for single file uploads.
What would be useful, so that users don't have to separately retrieve the individual objects in order to do things like show a more robust preview option in javascript, is to return an array of fileInfo objects for each of the files in the group. I suspect it's trivial to do this inside the react library itself as the network call to /group
already returns this info.
Hi @thongly, thanks for the suggestion! Using the Dialog API, you can get an array of file objects from the widget and then get information about each object. Here's how you can do this
<Widget
publicKey="demopublickey"
onDialogOpen={(dialog) => {
// fires when a user closes the widget's dialog (clicks Done)
dialog.done(async (group) => {
// get an array of file instances and fileInfo objects
const fileInfos = await Promise.all(group.files());
console.log(fileInfos);
});
}}
multiple
/>
We'll definitely consider simplifying this in the new uploader we're working on.
yes thanks! that's how i'm doing it in the meantime