How to use the react-dropzone/dist/es/utils.fileAccepted function in react-dropzone

To help you get started, we’ve selected a few react-dropzone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github datavized / twotone / src / components / AssetSelectDialog.js View on Github external
onDrop = async (acceptedFiles, rejectedFiles) => {
		const { assetLibrary, getFileData } = this.props;
		const assets = [];
		const files = new Set();

		this.setState({
			processing: true,
			progress: 0,
			errorMessage: ''
		});

		let errorMessage = '';
		if (rejectedFiles.length) {
			const file = rejectedFiles[0];
			if (this.props.accept && !fileAccepted(file, this.props.accept)) {
				errorMessage = `Unsupported file type.`;
			} else if (file.size > this.props.maxSize) {
				errorMessage = `File is too big.`;
			} else {
				errorMessage = `Error importing file.`;
			}
			errorMessage += ` (${file.name})`;
		}

		for (let i = 0; i < acceptedFiles.length && !errorMessage; i++) {
			const file = acceptedFiles[i];
			try {
				let assetData = await getFileData(file);
				if (assetData) {
					if (!Array.isArray(assetData)) {
						assetData = [assetData];

react-dropzone

Simple HTML5 drag-drop zone with React.js

MIT
Latest version published 4 days ago

Package Health Score

97 / 100
Full package analysis