Skip to content

Instantly share code, notes, and snippets.

@codeBelt
Last active January 3, 2021 20:33
Show Gist options
  • Save codeBelt/b922c894b18219b64bab0303ec35853e to your computer and use it in GitHub Desktop.
Save codeBelt/b922c894b18219b64bab0303ec35853e to your computer and use it in GitHub Desktop.
export const IndexPage = (props) => {
const onChange = async (formData) => {
const config = {
headers: { 'content-type': 'multipart/form-data' },
onUploadProgress: (event) => {
console.log(`Current progress:`, Math.round((event.loaded * 100) / event.total));
},
};
const response = await axios.post('/api/uploads', formData, config);
console.log('response', response.data);
};
return (
<UiFileInputButton
label="Upload Single File"
uploadFileName="theFiles"
onChange={onChange}
/>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment