import * as React from 'react'; import { Amplify } from 'aws-amplify'; import { withAuthenticator } from '@aws-amplify/ui-react'; import { Field } from '@aws-amplify/ui-react/internal'; import { StorageManager } from '@aws-amplify/ui-react-storage'; import '@aws-amplify/ui-react/styles.css'; import awsExports from './aws-exports'; Amplify.configure(awsExports); export function StorageManagerExample() { const [files, setFiles] = React.useState({}); return ( { setFiles((prevFiles) => { return { ...prevFiles, [key]: undefined, }; }); }} onUploadError={(error, { key }) => { setFiles((prevFiles) => { return { ...prevFiles, [key]: { status: 'error', }, }; }); }} onUploadSuccess={({ key }) => { setFiles((prevFiles) => { return { ...prevFiles, [key]: { status: 'success', }, }; }); }} onUploadStart={({ key }) => { setFiles((prevFiles) => { return { ...prevFiles, [key]: { status: 'uploading', }, }; }); }} /> {Object.keys(files).map((key) => { return files[key] ? (
{key}: {files[key].status}
) : null; })}
); } export default withAuthenticator(StorageManagerExample);