1.0.2 • Published 4 years ago

react-file-upload-mobile v1.0.2

Weekly downloads
47
License
MIT
Repository
github
Last release
4 years ago

react-file-upload-mobile


React Mobile Single File Upload Component

NPM version npm download

Screenshots

  • Upload mode - To be uploaded

  • Upload mode - Uploaded

  • Display mode

install

react-file-upload-mobile

Usage

    import ReactFileUploadMobile from 'react-file-upload-mobile';

    const [image, setImage] = useState();
    const [imageName, setImageName] = useState();
    const clearAttachment = () => {
        setImage('');
        setImageName('');
    }
    const onUpload = (file) => {
        // upload api
    }
    const preview = () => {
        // preview picture
    }
    // Upload mode
    <ReactFileUploadMobile
        fileUrl={image}
        fileName={imageName}
        displayOnly={false}
        preview={preview}
        compressImg={0.8}
        onFileDelete={clearAttachment}
        onFileUpload={onUpload}
        showNote={true}
        uploadSuffix={['docx', 'doc', 'jpg', 'png', 'jpeg', 'zip']}
        uploadImgSuffix={['jpg', 'png', 'jpeg']}
    />
    // Display mode
    <ReactFileUploadMobile
        fileUrl={'//xxx.com/xxx.jpg'}
        fileName={'xxx.jpg'}
        preview={preview}
        download={true}
        displayOnly={true}
    />

API

PropertiesDescritionTypeDefault
wrapClsWrap classNamestring-
fileUrlFile urlstring-
fileNameFile namestring-
displayOnlyDisplay mode or upload modebooleanfalse
downloadDownloading file Display mode onlybooleanfalse
compressImgPicture compression ratio, Upload mode only, One decimal place between 0-1, 0 or 1 is uncompressednumber0.8
showNoteShow bottom text, Upload mode onlybooleanfalse
uploadSuffixSuffix restrictions on uploaded files, Upload mode onlyArray[]
uploadImgSuffixPicture file suffix,Subset of uploadSuffix, Upload mode onlyArray[]

Methods

  • preview() - Click thumbnail callback
  • onFileDelete() - Clicking delete button callback, Upload mode only
  • onFileUpload(file: File) - File upload callback, Upload mode only

Development

Modify the file under source,npm run build will compile, other functions have not been implemented yet

TODOs

  • Globalization
  • Add parameter: file name length limit
  • Add parameter: file size limit

Example

Tips

Test Case

Coverage

License

react-file-upload-mobile is released under the MIT license.

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.3.0

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.1.10

4 years ago

0.2.0

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.9

4 years ago

0.1.6

4 years ago

0.1.2

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.5

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago