valor-software/ng2-file-upload

Name: ng2-file-upload

Owner: Valor Software

Description: Easy to use Angular2 components for files upload

Created: 2015-08-27 09:48:28.0

Updated: 2018-01-19 03:54:54.0

Pushed: 2017-12-20 15:41:02.0

Homepage: http://valor-software.github.io/ng2-file-upload/

Size: 17808

Language: TypeScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

ng2-file-upload npm version npm downloadsslack

Easy to use Angular2 directives for files upload (demo)

Angular 2 Style Guide Build Status Dependency Status

Quick start
  1. A recommended way to install ng2-file-upload is through npm package manager using the following command:

    npm i ng2-file-upload --save

    Alternatively, you can download it in a ZIP file.

  2. Currently ng2-file-upload contains two directives: ng2-file-select and ng2-file-drop. ng2-file-select is used for 'file-input' field of form and ng2-file-drop is used for area that will be used for dropping of file or files.

  3. More information regarding using of ng2-file-upload is located in demo and demo sources.

Using ng2-file-upload in a project
  1. Install as shown in the above section.

  2. Import FileUploadModule into the module that declares the component using ng2-file-upload:

dd it to `[imports]` under `@NgModule`:
  1. Import FileUploader into the component:
reate a variable for the API url:
  1. Initialize it:
PI for `ng2FileSelect`

Properties

`uploader` - (`FileUploader`) - uploader object. See using in [demo](https://github.com/valor-software/ng2-file-upload/blob/master/demo/components/file-upload/simple-demo.ts)

Events
onFileSelected` - fires when files are selected and added to the uploader queue

PI for `ng2FileDrop`

Properties

`uploader` - (`FileUploader`) - uploader object. See using in [demo](https://github.com/valor-software/ng2-file-upload/blob/master/demo/components/file-upload/simple-demo.ts)

rameters supported by this object:

 `url` - URL of File Uploader's route
 `authToken` - Auth token that will be applied as 'Authorization' header during file send.
 `disableMultipart` - If 'true', disable using a multipart form for file upload and instead stream the file. Some APIs (e.g. Amazon S3) may expect the file to be streamed rather than sent via a form. Defaults to false.
 `itemAlias` - item alias (form name redefenition)
 `formatDataFunction` - Function to modify the request body. 'DisableMultipart' must be 'true' for this function to be called.
 `formatDataFunctionIsAsync` - Informs if the function sent in 'formatDataFunction' is asynchronous. Defaults to false.
 `parametersBeforeFiles` - States if additional parameters should be appended before or after the file. Defaults to false.

Events

`fileOver` - it fires during 'over' and 'out' events for Drop Area; returns `boolean`: `true` if file is over Drop Area, `false` in case of out.
e using in [ts demo](https://github.com/valor-software/ng2-file-upload/blob/master/demo/components/file-upload/simple-demo.ts) and
tml demo](https://github.com/valor-software/ng2-file-upload/blob/master/demo/components/file-upload/simple-demo.html)
`onFileDrop` - it fires after a file has been dropped on a Drop Area; you can pass in `$event` to get the list of files that were dropped. i.e. `(onFileDrop)="dropped($event)"`

oubleshooting

se follow this guidelines when reporting bugs and feature requests:

se [GitHub Issues](https://github.com/valor-software/ng2-file-upload/issues) board to report bugs and feature requests (not our email address)
lease **always** write steps to reproduce the error. That way we can focus on fixing the bug, not scratching our heads trying to reproduce it.

ks for understanding!

License

MIT License (see the [LICENSE](https://github.com/valor-software/ng2-file-upload/blob/master/LICENSE) file for the full text)

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.