<commit_before># Ng2Upload

## ng2-upload [![Angular 2 Style Guide](https://mgechev.github.io/angular2-style-guide/images/badge.svg)](https://github.com/mgechev/angular2-style-guide)

Follow me [![twitter](https://img.shields.io/twitter/follow/babarxm.svg?style=social&label=%20babarxm)](https://twitter.com/babarxm) to be notified about new releases.

## Setup
`npm install ng2-upload --save`

## Properties and methods
  - `addFile(file, options)` add a file to the queue with options (options are optional).
  - `addFiles(files[], options)` add a file to the queue with options (options are optional).
  - `clearQueue()` remove all files from queue.
  - `removeFile(index)` remove a specific file from queue.
  - `setOptions(options)` should set global options for upload applied for each upload.
  - `uploadAll()` upload all files from queue.
  - `uploadOne(index)` upload a specific file from queue.
  - `uploadFile(file, options)` upload a file directly without adding to queue.
  - `queue` array of files to be upload.

## Each item properties
  - `progress` upload progress of the item.
  - `status` holds upload flag.
  - `onUploadComplete` observable which emits data after each upload completed with response.

## Configuration
### Simple upload example
#### To check full functionality locate demo directory files
    import { Ng2Uploader, Ng2UploaderOptions } from "ng2-upload";
    @Component({
      selector: '',
      template: ''
    })
    export class DemoComponent {
      uploader: Ng2Uploader;
      options: Ng2UploaderOptions;
      files: [];
      constructor(){
        this.files = [...] // Array of file objects
        this.options = {
          url: "http://xyz.com/upload",
          headers: { "Authorization": "Bearer asd", "Accept" : "something" },
          params: { "param1": "val1", "param2": "val2" }
        };
        this.uploader = new Ng2Uploader(this.options); // Global options applied for each upload
        this.uploader.addFiles(this.files);
        this.uploader.uploadAll();
      }
    }

### Example with each file options
    import { Ng2Uploader, Ng2UploaderOptions } from "ng2-upload";
    @Component({
      selector: '',
      template: ''
    })
    export class DemoComponent {
      uploader: Ng2Uploader;
      files: [];
      constructor(){
        this.files = {} // File object
        this.uploader = new Ng2Uploader();
        this.options = {
          url: "http://xyz.com/upload",
          headers: { "Authorization": "Bearer asd", "Accept" : "something" },
          params: { "param1": "val1", "param2": "val2" }<commit_msg>description updated<commit_after># Ng2Upload

## ng2-upload [![Angular 2 Style Guide](https://mgechev.github.io/angular2-style-guide/images/badge.svg)](https://github.com/mgechev/angular2-style-guide)

Follow me [![twitter](https://img.shields.io/twitter/follow/babarxm.svg?style=social&label=%20babarxm)](https://twitter.com/babarxm) to be notified about new releases.

## Setup
`npm install ng2-upload --save`

## Properties and methods
  - `addFile(file, options)` add a file to the queue with options (options are optional).
  - `addFiles(files[], options)` add a file to the queue with options (options are optional).
  - `clearQueue()` remove all files from queue.
  - `removeFile(index)` remove a specific file from queue.
  - `setOptions(options)` should set global options for upload applied for each upload.
  - `uploadAll()` upload all files from queue.
  - `uploadOne(index)` upload a specific file from queue.
  - `uploadFile(file, options)` upload a file directly without adding to queue.
  - `queue` array of files to be upload.

## Each item properties
  - `progress` upload progress of the item.
  - `status` holds upload flag.
  - `onUploadComplete` observable which emits data after each upload completed with response.

## Configuration
### Simple upload example
#### To check full functionality locate demo directory files
    import { Ng2Uploader, Ng2UploaderOptions } from "ng2-upload";
    @Component({
      selector: '',
      template: ''
    })
    export class DemoComponent {
      uploader: Ng2Uploader = new Ng2Uploader();
      options: Ng2UploaderOptions;
      files: [];
      constructor(){
        this.files = [...] // Array of file objects
        this.options = {
          url: "http://xyz.com/upload",
          headers: { "Authorization": "Bearer asd", "Accept" : "something" },
          params: { "param1": "val1", "param2": "val2" }
        };
        this.uploader.setOptions(this.options); // Global options applied for each upload
        this.uploader.addFiles(this.files);
        this.uploader.uploadAll();
      }
    }

### Example with each file options
    import { Ng2Uploader, Ng2UploaderOptions } from "ng2-upload";
    @Component({
      selector: '',
      template: ''
    })
    export class DemoComponent {
      uploader: Ng2Uploader = new Ng2Uploader();
      files: [];
      constructor(){
        this.files = {} // File object
        this.uploader = new Ng2Uploader();
        this.options = {
          url: "http://xyz.com/upload",
          headers: { "Authorization": "Bearer asd", "Accept" : "something" },
          params: { "param1": "val1", "param2": "val2" }
{'fraction_non_alphanumeric': 0.1327990841442473, 'fraction_numerical': 0.0104941804999046, 'mean_word_length': 3.0385208012326657, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2904969', 'n_tokens_mistral': 1555, 'n_tokens_neox': 1518, 'n_words': 457}