Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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];