1.0.19 • Published 8 months ago

andorlh-files v1.0.19

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

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)
}
1.0.19

8 months ago

1.0.18

8 months ago

1.0.17

8 months ago

1.0.16

8 months ago

1.0.15

8 months ago

1.0.14

8 months ago

1.0.13

8 months ago

1.0.12

8 months ago

1.0.11

8 months ago

1.0.10

8 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago