| 215 | } |
| 216 | |
| 217 | handleAddFile(files) { |
| 218 | files = Array.from(files); |
| 219 | const filesSize = files.reduce((total, file) => total + file.size, 0); |
| 220 | const uploadedSize = this.state.files.reduce((total, file) => total + file.size, 0); |
| 221 | const currentAttachmentsSize = uploadedSize + filesSize; |
| 222 | if (currentAttachmentsSize > MAX_FILE_UPLOAD_SIZE) { |
| 223 | this.setState({notifications: [{id: Date.now(), header: l10n.map.alert_header_error, message: `${l10n.map.upload_quota_exceeded_warning} ${Math.floor(MAX_FILE_UPLOAD_SIZE / (1024 * 1024))}MB.`, type: 'error'}]}); |
| 224 | return; |
| 225 | } |
| 226 | for (const file of files) { |
| 227 | try { |
| 228 | this.addFile(file); |
| 229 | } catch (error) { |
| 230 | this.setErrorNotification(error, file.name, 'upload'); |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | addFile(file) { |
| 236 | if (fileLib.isOversize(file)) { |