Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array of FileInfo objects back onSuccess of fileGroup upload #266

Open
thongly opened this issue May 30, 2021 · 2 comments
Open

Array of FileInfo objects back onSuccess of fileGroup upload #266

thongly opened this issue May 30, 2021 · 2 comments

Comments

@thongly
Copy link

thongly commented May 30, 2021

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.

@optlsnd
Copy link

optlsnd commented May 31, 2021

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.

@thongly
Copy link
Author

thongly commented May 31, 2021

yes thanks! that's how i'm doing it in the meantime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants