Gathering detailed insights and metrics for ngx-awesome-uploader-v2
Gathering detailed insights and metrics for ngx-awesome-uploader-v2
npm install ngx-awesome-uploader-v2
Typescript
Module System
Node Version
NPM Version
71.6
Supply Chain
95.7
Quality
75.5
Maintenance
50
Vulnerability
98.2
License
TypeScript (72.07%)
CSS (17.47%)
HTML (7.37%)
JavaScript (3.09%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
3,444
Last Day
2
Last Week
8
Last Month
32
Last Year
695
25 Commits
2 Watchers
32 Branches
4 Contributors
Updated on Dec 26, 2019
Latest Version
8.2.2
Package Id
ngx-awesome-uploader-v2@8.2.2
Unpacked Size
938.94 kB
Size
191.55 kB
File Count
86
NPM Version
6.13.4
Node Version
12.13.0
Cumulative downloads
Total Downloads
Last Day
0%
2
Compared to previous day
Last Week
300%
8
Compared to previous week
Last Month
-75%
32
Compared to previous month
Last Year
20.9%
695
Compared to previous year
1
2
This is an Angular Library for uploading files. It supports: File Upload and Preview (additionally preview images with lightbox), validation, image cropper , drag and drop with multi language support.
Tested on Angular 6/7/8. Supports Server Side Rendering.
Example Application or StackBlitzDemo
npm install ngx-awesome-uploader-v2 --save
1import { FilePickerModule } from 'ngx-awesome-uploader-v2'; 2@NgModule({ 3imports: [ 4... 5FilePickerModule 6] 7}) 8
In order to make library maximum compatible with apis you need to create and provide custom adapter which implements upload and remove requests. That's because I have no idea how to get file id in upload response json :) . So this libray exposes a FilePickerAdapter abstract class which you can import on your new class file definition:
import { FilePickerAdapter } from 'ngx-awesome-uploader-v2';
After importing it to your custom adapter implementation (EG: CustomAdapter.ts), you must implement those 2 methods which are abstract in the FilePickerAdapter base class which are:
public abstract uploadFile(fileItem: FilePreviewModel): Observable<number | string>;
public abstract removeFile(fileItem: FilePreviewModel): Observable<any>;
Note: Since uploadFile method will use http progress event, it has to return id of file (in string type only) in case of HttpEventType.Response type, or progress (in number type) in case of HttpEventType.UploadProgress. You will receive this id on removeFile method when you click remove.
You can check DEMO adapter here
1<ngx-file-picker [adapter]="adapter"> </ngx-file-picker>
1import { HttpClient } from "@angular/common/http"; 2import { DemoFilePickerAdapter } from "./demo-file-picker.adapter"; 3import { Component } from "@angular/core"; 4@Component({ 5 selector: "demo-file-picker", 6 templateUrl: "./demo-file-picker.component.html", 7 styleUrls: ["./demo-file-picker.component.scss"] 8}) 9export class DemoFilePickerComponent { 10 adapter = new DemoFilePickerAdapter(this.http); 11 constructor(private http: HttpClient) {} 12}
Note: As you see you should provide http instance to adapter. Still in Doubt? Check Minimal Setup Demo
1/** Whether to enable cropper. Default: disabled */ 2@Input() enableCropper = false; 3 4/** Whether to show default drag and drop template. Default:true */ 5@Input() showeDragDropZone = true; 6 7/** Single or multiple. Default: multi */ 8@Input() uploadType = 'multi'; 9 10/** Max size of selected file in MB. Default: no limit */ 11@Input() fileMaxSize: number; 12 13/** Max count of file in multi-upload. Default: no limit */ 14@Input() fileMaxCount: number; 15 16/** Total Max size limit of all files in MB. Default: no limit */ 17@Input() totalMaxSize: number; 18 19/** Which file types to show on choose file dialog. Default: show all */ 20@Input() accept: string; 21 22/** File extensions filter. Default: any exteion */ 23@Input() fileExtensions: String; 24 25/** Cropper options if cropper enabled. Default: 26 dragMode: 'crop', 27 aspectRatio: 1, 28 autoCrop: true, 29 movable: true, 30 zoomable: true, 31 scalable: true, 32 autoCropArea: 0.8 33*/ 34@Input() cropperOptions: Object; 35 36/** Custom Adapter for uploading/removing files. Required */ 37@Input() adapter: FilePickerAdapter; 38 39/** Custom template for dropzone. Optional */ 40@Input() dropzoneTemplate: TemplateRef<any>; 41 42/** Custom Preview Item template. Optional */ 43@Input() itemTemplate: TemplateRef<any>; 44 45/** Whether to show default files preview container. Default: true */ 46@Input() showPreviewContainer = true; 47 48/** Custom validator function. Optional */ 49@Input() customValidator: (file: File) => Observable<boolean>; 50 /** Custom captions input. Used for multi language support */ 51@Input() captions: UploaderCaptions; 52 53 /** Custom predefined files */ 54@Input() images: ImagePreviewModel;
1/** Emitted when file is uploaded via api successfully. 2Emitted for every file */ 3@Output() uploadSuccess = new EventEmitter<FilePreviewModel>(); 4/** Emitted when file is removed via api successfully. 5 Emitted for every file */ 6@Output() removeSuccess = new EventEmitter<FilePreviewModel>(); 7/** Emitted on file validation fail */ 8@Output() validationError = new EventEmitter<ValidationError>(); 9/** Emitted when file is added and passed validations. Not uploaded yet */ 10@Output() fileAdded = new EventEmitter<FilePreviewModel>();
All validations are emitted through ValidationError event. To listen to validation errors (in case you provided validations), validationError event is emitted. validationError event implements interface ValidationError and which emits failed file and error type. Supported validations:
Validation Type | Description | Default |
---|---|---|
fileMaxSize: number | Max size of selected file in MB. | No limit |
fileExtensions: String | Emitted when file does not satisfy provided extension | Any extension |
uploadType: String | Upload type. Values: 'single' and 'multi'. | multi |
totalMaxSize: number | Total Max size of files in MB. If cropper is enabled, the cropped image size is considered. | No limit |
fileMaxCount: number | Limit total files to upload by count | No limit |
You can also provide your own custom validation along with built-in validations.
You custom validation takes file: File
and returns Observable<boolean>
;
So that means you can provide sync and async validations.
myCustomValidator(file: File): Observable<boolean> {
if (file.name.includes('panda')) {
return of(true);
}
if (file.size > 50) {
return this.http.get('url').pipe(map((res) => res === 'OK' ));
}
return of(false);
}
and pass to Template:
1<ngx-file-picker [customValidator]="myCustomValidator"> </ngx-file-picker>
Check Demo
Library uses cropperjs to crop images but you need import it to use it. Example: in index html
1<script 2 src="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.4.3/cropper.min.js" 3 async 4></script> 5<link 6 rel="stylesheet" 7 href="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.4.3/cropper.css" 8/>
Note: To use cropper, you should set enableCropper to true. Look at API section above. You can also provide your custom cropper options.
You can provide custom template to library.
I) To provide custom template for drag and drop zone, use content projection. Example:
1<ngx-file-picker [adapter]="adapter"> 2 <div class="dropzoneTemplate"> 3 <button>Custom</button> 4 </div> 5</ngx-file-picker>
Note: The wrapper of your custom template must have a class dropzoneTemplate.
II) To use custom file preview template, pass your custom template as below:
1<ngx-file-picker #uploader [adapter]="adapter" [itemTemplate]="itemTemplate"> 2</ngx-file-picker> 3 4<ng-template 5 #itemTemplate 6 let-fileItem="fileItem" 7 let-uploadProgress="uploadProgress" 8> 9 <p>{{fileItem.file.size}}</p> 10 <p>{{fileItem.fileName}}</p> 11 <p *ngIf="uploadProgress < 100">{{uploadProgress}}%</p> 12 <button (click)="uploader.removeFile(fileItem)">Remove</button> 13</ng-template>
In custom template uploadProgress and fileItem (which implements FilePrevieModel interface) are exposed .
You can add multi language support for library by providing captions object (which implements UploaderCaptions interface).
Check Demo
You can also check out library router animations
You can fork project from github. Pull requests are kindly accepted.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 0/25 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
146 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More