| Server IP : 93.86.61.54 / Your IP : 216.73.216.60 Web Server : Apache/2.4.62 (Ubuntu) System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64 User : www-data ( 33) PHP Version : 8.4.22 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/projects/nextcloud/apps/logreader/js/Components/ |
Upload File : |
import {Component} from 'react';
import Dropzone from 'react-dropzone';
import style from './LogUploader.css';
export class LogUploader extends Component {
state = {
message: 'Load log file...'
};
isLog (content) {
return content[0] === '{' && content[content.length - 1] === '}';
}
onDrop = (files) => {
const file = files[0];
const reader = new FileReader();
reader.onload = (e) => {
const content = e.target.result.trim();
if (!this.isLog(content)) {
this.setState({message: 'Invalid log file'});
return;
}
this.props.onLogFile(content);
};
reader.readAsText(file);
};
render () {
const dropStyle = {
display: 'inline-block',
margin: '5px'
};
return (
<Dropzone multiple={false} accept="text/*" className={"button"} style={dropStyle}
onDrop={this.onDrop}>
{({getRootProps, getInputProps}) => <button {...getRootProps()}>{this.state.message}<input {...getInputProps()}/></button>}
</Dropzone>
);
}
}