npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-file-upload-library

v1.2.0

Published

Vue JS 3 single/multiple file uploader. We Just need to pass configuration as an input all the work handle by uploader component based on passed configuration

Downloads

8

Readme

Vue JS single/multipe file uploader

Vue JS 3 single/multiple file uploader. We Just need to pass configuration as an input all the work handle by uploader component based on passed configuration

Features

  • Multiple File Uploads
  • Max File Size, Accepted file types validation
  • differentiate valid/invalid files as per passed cofiguration
  • We can passed files type what we want to upload
  • Upload files on the basis of passed configuration
  • File input with drag and drop with support for folders
  • Provide lot of other methods so that we can handle files as per our requirements
  • Default uploader with progress
  • Externally controllable via Vue bindings and methods

How we use Vue js file uploader in our application

Basic Usage

  <FileUploader
      ref="fileUploader"
      :multiple="true"
      :config="config"
      @fileUploadEmitter="fileUploadHandler($event)"
      @filesEmitter="handleFiles($event)"
    /></FileUploader>

config should be in below format

config: {
        maxSize: 10,
        uploadConfig: {
          url: "test url",
          method: "POST",
          userRef: "test user",
        },
        formatsAllowed: ".jpg, .png, .mp4"
      }
we can pass uploadConfig in case we want to upload files from uploader. fileUploadEmitter event will trigger in case success/failure with the service response. Max Size will used user to restrict files upload within provide files size. Our uploader will consider maxSize in MB. formatsAllowed will be use in case we want user to restrict file types to upload

| Input | Type | Purpose | | ------ | ------ | ------ | | multiple:required | boolean | true in case we want to upload multiple files otherwise false | | config: required |object | File Configurations |

Events

| Output | Purpose | | ------ | ------ | | fileUploadEmitter | Trigger in case we are trying to upload files using file uploader, we can upload files using component own handler as well| | filesEmitter | Trigger every time when user select files, reset files, remove particular file with provide information number of valid/invalid files|

fileUploadEmitter always return data in this format
this.$emit("fileUploadEmitter", { success: true, response: result });
this will work in case we are handling file upload from uploader by passing upload url in configuration.
success true means files are uploaded, false means some errors from service
filesEmitter always return data in this format
this.$emit("filesEmitter", {
        validFiles: this.allowedFiles,
        invalidFiles: this.notAllowedFiles,
      });
<script>
  export default {
    data() {
      return {
        // ...
        fileRecords: [],
        config: {
        maxSize: 10,
        uploadConfig: {
          url: "test url",
          method: "POST",
          userRef: "test user, this is user token we will use as a bearer",
        },
        formatsAllowed: ".jpg, .png, .mp4",
      }
        // ...
      };
    },
    // ...
  };
</script>

Installation

npm install vue-file-upload-library --save
import Vue from 'vue';
import FileUploader from 'vue-file-upload-library';

Vue.use(VueFileAgent);

how we use uploader component methods

As we can see we are creating file uploader component object above which is 'fileUploader'. We will use this object to access file uploader methods
1. Suppose we have selected 10 files and want to remove one of them. we will use removeValidFiles() method like this.
this.$refs.fileUploader.removeValidFiles(fileIndex)
2. Suppose we have selected some files to be upload and one of them are invalid like size exceed and we want to remove these files. we will use removeInvalidFiles() method like this.
this.$refs.fileUploader.removeInvalidFiles(fileIndex)
Both of the above methods will return emitter with the updated count of files like this:
this.$emit("filesEmitter", {
        validFiles: this.allowedFiles,
        invalidFiles: this.notAllowedFiles,
      });
3. We want to remove all the files we have selected, we will use
this.$refs.fileUploader.resetFiles(fileIndex). This method will return emitter with updated files like this:
this.$emit("filesEmitter", {
        validFiles: this.allowedFiles,
        invalidFiles: this.notAllowedFiles,
      });
4. Suppose we want to upload files using file uploader component, we just need to use that particular method:
this.$refs.fileUploader.fileUpload()
to execute this method properly we need to pass apiUrl, method and logged in user token in the configuration. Refer to config format in the starting of our read me file

License

The MIT License