andorlh-files
v1.0.19
Published
Files management
Downloads
6
Readme
Install
- npm i --save andorlh-files
import { FileDialog } from 'andorlh-files';
this.fileDialogRef = React.createRef();
buttonOpen_onClick(e) { let me = this; e.preventDefault();
const successCallback = function (file, data) {
let x = 0;
if (file.type == 'application/pdf') {
me.openPdf(file, data);
} else {
const text = me.uint8ArrayToString(data);
me.setState({
text: text
})
}
}
const errorCallback = function (error) {
let x = 0;
alert(error);
}
this.fileDialogRef.current.open("*.*", successCallback, errorCallback)
}
buttonSave_onClick(e) {
let me = this;
e.preventDefault();
let data = this.stringToUint8Array(this.state.text);
let defaultFileName = "Document 1.txt";
let filter = "*.*";
const successCallback = function (fileName) {
let x = 0;
alert(fileName);
}
const cancelCallback = function () {
let x = 0;
alert("Canceleled.");
}
this.fileDialogRef.current.save(data, defaultFileName, filter, successCallback, cancelCallback)
}