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

file-upload-angular

v1.4.0

Published

Angular single/multiple file uploader. We Just need to pass configuration as an input all the work handle by uploader component based on passed configuration. We can pass custom text in files upload button, we can check valid/invalid files list in dialog

Downloads

6

Readme

Angular single/multipe file uploader

Angular single/multiple file uploader. We Just need to pass configuration as an input all the work handle by uploader component based on passed configuration. We can pass custom text in files upload button, we can check valid/invalid files list in dialog and select which files we want to upload from the selected files list using files uploader. Demo URL attached with this version

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
  • Provide lot of other methods so that we can handle files as per our requirements
  • Externally controllable via Angular bindings and methods

Installation

npm install file-upload-angular --save

and import module in app.module file


import { FileUploadAngularModule } from 'file-upload-angular';

imports: [
    FileUploadAngularModule
]

Basic Usage

  <lib-file-upload
      #fileUploader
      [multiple]="false"
      [config]="config"
      [buttonText]="'Select Files'"
      (fileUploadEmitter)="fileUploadHandler($event)"
      (filesEmitter)="handleFiles($event)"
    ></lib-file-upload>

file upload config

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 | | ------ | ------ | ------ | | buttonText: required |string | upload button name you want to display in browser, like 'Select Files' | | 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.fileUploadEmitter.emit({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.filesEmitter.emit({
      validFiles: validFilesList,
      invalidFiles: invalidFilesList (in case max size exceed or invalid format),
    });

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.fileUploaderObj.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.fileUploaderObj.removeInvalidFiles(fileIndex)
Both of the above methods will return emitter with the updated count of files like this:
this.filesEmitter.emit({
      validFiles: validFilesList,
      invalidFiles: invalidFilesList (in case max size exceed or invalid format),
    });
3. We want to remove all the files we have selected, we will use
this.fileUploaderObj.resetFiles(fileIndex). This method will return emitter with updated files like this:
this.filesEmitter.emit({
      validFiles: validFilesList,
      invalidFiles: invalidFilesList (in case max size exceed or invalid format),
    });
4. Suppose we want to upload files using file uploader component, we just need to use that particular method:
this.fileUploaderObj.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

Demo

License

The MIT License