lazy-upload
TypeScript icon, indicating that this package has built-in type declarations

0.2.4 • Public • Published

Welcome to lazy-upload 👋

lazy-upload is a library which aims to simplify the file upload flow

Version Commit Activity Build Status Bundle Size

Installing

Using npm:

npm i --save lazy-upload

Using yarn:

yarn add --dev lazy-upload

Usage

Here are examples of how you can use lazy-upload.

useLazyUpload

File upload hook

Examples

Basic
const UPLOAD_FILES_URL = '';
 
export const UploadField = () => {
  const {
    acceptedFiles,
    attributes,
    rejectedFiles,
    reset,
    upload,
    uploadedFiles,
  } = useLazyUpload({});
  console.log({ rejectedFiles, uploadedFiles });
  return (
    <form
      onSubmit={e => {
        upload({
          config: {
            url: UPLOAD_FILES_URL,
            method: 'POST',
          },
          fileList: acceptedFiles,
        });
        e.preventDefault();
      }}
    >
      <label htmlFor="file-upload">Choose files:</label>
      <input {...attributes} id="file-upload" name="file-upload" />
      <button onClick={reset}>Reset</button>
      <button type="submit">Submit</button>
    </form>
  );
};

Running the tests

Tests are written with jest

Unit tests

Using jest:

yarn run test

Deployment

Deployment is done with Travis.

Built With

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

Show your support

Give a ⭐️ if this project helped you!

License

This project is licensed under the MIT License - see the LICENSE file for details

Dependents (0)

Package Sidebar

Install

npm i lazy-upload

Weekly Downloads

0

Version

0.2.4

License

MIT

Unpacked Size

43.3 kB

Total Files

12

Last publish

Collaborators

  • arnaud-zg