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

Handling multiple files with widget in react #290

Open
stevesizer opened this issue Dec 29, 2021 · 1 comment
Open

Handling multiple files with widget in react #290

stevesizer opened this issue Dec 29, 2021 · 1 comment
Labels

Comments

@stevesizer
Copy link

Question

Handling multiple files with the widget in react

The onchange method provides the fielGroup info which had a cdn for home files. How do I get each files cdn?

@optlsnd
Copy link

optlsnd commented Dec 29, 2021

You can use the onFileSelect method instead. It provides a group instance from which you can extract individual file URLs.

const Example = () => {
  return (
    <div>
      <Widget
        publicKey="demopublickey"
        multiple
        onFileSelect={async (group) => {
          const files = await Promise.all(group.files());
          const urls = files.map((file) => file.cdnUrl);
          console.log(urls);
        }}
      />
    </div>
  );
};
ReactDom.render(<Example />, document.querySelector("#app"));

Here's a demo on Codesandbox.

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

No branches or pull requests

2 participants