Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@j-lamberts/react-file-upload
Advanced tools
This packages provides some easy-to-use react components for file uploads. It contains
FileUploader
to manage all uploadsFileDropzone
as a simple dropzone wrapper-componentFileSelect
as a simple wrapper around <input type="file" />
import {
Button,
Icon,
LinearProgress
} from 'material-ui';
import * as React from 'react';
import {
FileDropzone,
FileSelect,
FileUploader
} from 'react-file-uploads';
export default () => (
<FileUploader
keepOnFinish={true}
url={'http://localhost:4005/files'}
>
{({ handleFiles, queue }) => (
<div>
<FileDropzone onDrop={handleFiles}>
{queue.map((el, index) => (
<div key={index}>
{index} {el.name}
<LinearProgress
variant={el.progressTotal
? 'determinate'
: 'indeterminate'}
value={el.progressLoaded / el.progressTotal * 100}
/>
</div>
))}
DROP FILES HERE
</FileDropzone>
<div>
Uploaded: {queue.length} <br/>
Waiting: {queue.filter(el => !el.ready).length}<br/>
Ready: {queue.filter(el => el.ready).length}
</div>
<FileSelect
onChange={handleFiles}
multiple={true}
>
<Icon>file_upload</Icon>Upload
</FileSelect>
</div>
)}
</FileUploader>
);
import {
Button,
Icon,
LinearProgress
} from 'material-ui';
import * as React from 'react';
import {
FileDropzone,
FileSelect,
FileUploader
} from 'react-file-uploads';
export default () => (
<FileUploader
runManual={true}
keepOnFinish={true}
url={'http://localhost:4005/files'}
>
{({ handleFiles, queue, runManual }) => (
<div>
<!--- as above -->
<Button onClick={runManual}>
<Icon>check</Icon> Run
</Button>
</div>
)}
</FileUploader>
);
Name | Type | Default | Description |
---|---|---|---|
url * | string | (required) | HTTP-URL |
children * | (props: FileUploaderChildrenProps) => React.ReactNode | (required) | child-component |
runManual | boolean | false | Don't run upload on handleFiles() - use runManual instead |
keepOnFinish | boolean | false | Keep uploaded files in queue |
fieldName | string | 'file' | Form-Field |
method | 'POST' / 'PATCH' / 'PUT' | 'POST' | HTTP-Method |
headers | Object | {} | HTTP-Headers |
interface FileUploaderChildrenProps {
handleFiles: ((list: File[]) => void);
queue: FileUpload[];
runManual: () => void
}
interface FileUpload {
progressTotal: number;
progressLoaded: number;
error: boolean;
ready: boolean;
upload: XHRUpload; // don't access directly
name: string;
}
Name | Type | Default | Description |
---|---|---|---|
onDrop * | (files: File[]) => void | (required) | handler function |
children * | React.ReactNode ; | (required) | |
className | string | undefined | |
classNameActive | string | undefined | class-name on dragActive |
style | React.CSSProperties | undefined |
Name | Type | Default | Description |
---|---|---|---|
onChange: (files: File[]) => void | (required) | handler function | |
children | React.ReactNode | (required) | |
multiple | boolean | false | |
className | string | undefined | |
style | React.CSSProperties | undefined |
FAQs
File uploader for react.
We found that @j-lamberts/react-file-upload demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.