New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ngx-uploadx

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-uploadx

Angular Resumable Upload Module

  • 1.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9K
decreased by-21.27%
Maintainers
1
Weekly downloads
 
Created
Source

ngx-uploadx

Angular Resumable Upload Module

npm version Build status

Key Features

  • Pause / Resume / Cancel Uploads
  • Retries using exponential back-off strategy
  • Chunking

Setups

  • Add ngx-uploadx module as dependency :
  npm install ngx-uploadx
  • Import UploadxModule in the root module:
//...
import { UploadxModule } from 'ngx-uploadx';

@NgModule({
  imports: [
    UploadxModule,
   // ...
});

Basic usage

// Component code
//...
import { Observable } from 'rxjs';
import { UploadxOptions, UploadState } from 'ngx-uploadx';

@Component({
  selector: 'app-home',
  templateUrl: `
  <input type="file" [uploadx]="options" (uploadxState)="onUpload($event)">
  `
})

export class AppHomeComponent {
  options: UploadxOptions = { url: `[URL]`};
  onUpload(state: Observable<UploadState>) {
    state
      .subscribe((item: UploadState) => {
         console.log(item);
         //...
      }
 }

Server-side setup

Directive

<input type="file" [uploadx]="options" [uploadxAction]="control" (uploadxState)="onUpload($event)">

Selector

[uploadx]

inputs

  • [uploadx]: UploadxOptions
  • [uploadxAction]: UploadxControlEvent

Output

  • (uploadxState): $event <Observable>UploadState

Service

UploadxService

Public Methods

  • init(options: UploadxOptions): Observable<UploadState>

    Set global module options

    // example:
    
    ngOnInit() {
      this.uploadService.init(this.uploadxOptions)
        .subscribe((item: UploadState) => {
          console.log(item);
          //...
        }
    }
    
  • handleFileList(fileList: FileList): void

    Add files to the upload queue

  • control(event: UploadxControlEvent): void

    Send event

    // example:
    
    pause(uploadId: string) {
      this.uploadService.control({ action: 'pause', uploadId });
    }
    

Interfaces

UploadxOptions

NameDefaults?Description
[allowedTypes]-Set "accept" attribute
[autoUpload]trueAuto upload with global options
[chunkSize]0If set to > 0 use chunked upload
[concurrency]2Limit the number of concurrent uploads
[headers]-Custom headers
[method]"POST"Upload API initial method
[token]-Auth Bearer token
[url]"/upload/"API URL
[withCredentials]falseUse withCredentials xhr option

<Observable> UploadState

NameTypeDescription
fileFileFileAPI File
namestringfile name
progressnumberprogress percentage
remainingnumberETA
responseanysuccess/error response
sizenumberfile size
speednumberupload speed bytes/sec
statusUploadStatus'added', 'queue', 'uploading', 'complete', 'error', 'cancelled', 'paused'
uploadIdstringUnique upload id
URIstringsession URI

UploadItem

Item custom options, override globals

NameTypeDescription
[method]stringAPI initial method
[uploadId]stringUnique upload id ( ReadOnly )
[url]stringItem URL
[headers]{ [key: string]: string } | FunctionAdd custom headers
[metadata]anyAdd custom data

UploadxControlEvent

NameTypeDescription
actionUploadAction'uploadAll', 'upload', 'cancel', 'cancelAll', 'pauseAll, 'pause'
[uploadId]stringUnique upload id ( ReadOnly )
[itemOptions]UploadItemItem custom options

Run demo

  • Start server npm run server
  • Run demo app npm start
  • Navigate to http://localhost:4200/

Build

Run npm run build to build the lib.

packaged by ng-packagr

Contributing

Pull requests are welcome!

License

The MIT License (see the LICENSE file for the full text)

Keywords

FAQs

Package last updated on 28 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc