How to get file object using file button widget?

How to get the file object using the file button widget? Or is there any other component which gives the file object when we select an image file ?

Hey @dheeraj,

Try:

  • Enabling the "Parse Files" option in your file component
  • Accessing the parsed file via .parsedValue

Does that work for you?

I actually created a custom component to achieve this, where I specified the input type as file . Simple. Thanks @minijohn.

const { Input } = window["material-ui"];
const MyCustomComponent = ({ triggerQuery, model, modelUpdate }) => (
<Input
color="primary"
variant="outlined"
value={model.textInputValue}
type="file"
onChange={(e) => {
modelUpdate({ fileobject: e.target.files[0] }),
console.log("event", e.target.files);
}}
/>
);
const ConnectedComponent = Retool.connectReactComponent(MyCustomComponent);
ReactDOM.render(, document.getElementById("react"));

1 Like