Skip to content

Commit b5873b7

Browse files
committed
Release 1.0.0
1 parent 681f3ff commit b5873b7

34 files changed

+9564
-5853
lines changed

.angular-cli.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
33
"project": {
4-
"name": "ngx-if"
4+
"name": "ngx-input-file"
55
},
66
"apps": [
77
{

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# See http://help.github.com/ignore-files/ for more about ignoring files.
22

33
# compiled output
4-
.ng_build
4+
/.ng_pkg_build
5+
/dist
6+
/dist-server
57
/tmp
68
/out-tsc
79

README.md

+23-25
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
## Breaking changes
2+
Input file repository dropped.
3+
See below how to upload a file.
4+
15
# ngx-input-file
26

37
**ngx-input-file** is a module to replace the html element input file and also allows you to upload files.
48
Style is based on [Bootstrap File Input](http://plugins.krajee.com/file-input/demo).
5-
The component is compatible with [Bootstrap 4 beta](https://getbootstrap.com/).
9+
The component is compatible with [Bootstrap 4](https://getbootstrap.com/).
610

711
![Input File screenshot](http://img4.hostingpics.net/pics/626115inputfile1.png)
812

@@ -13,35 +17,24 @@ The component is compatible with [Bootstrap 4 beta](https://getbootstrap.com/).
1317
- Drag and drop zone
1418
- Responsive
1519
- [Font Awesome](http://fontawesome.io/) support
16-
- Uploads files with headers like `Authorization` (deprecated, other modules uploads files better than this one)
1720

1821
## Installation
1922
```bash
2023
npm install ngx-input-file --save
2124
```
2225

23-
## Basic Configuration (deprecated)
24-
The goal of this module is not to upload file but to provide a component to replace the html element input.
25-
Create a new `ngx-input-file.module.ts` file with the following code:
26-
```ts
26+
## Basic Configuration
27+
```typescript
2728
import { NgModule } from '@angular/core';
28-
import { InputFileModule, InputFileOptions, InputFileRepository } from 'ngx-input-file';
29+
import { InputFileModule } from 'ngx-input-file';
2930

30-
const options: InputFileOptions = new InputFileOptions(
31-
'auth-token-value',
32-
'Authorization'
33-
);
3431

3532
@NgModule({
3633
imports: [ InputFileModule ],
3734
exports: [ InputFileModule ]
3835
})
3936

40-
export class NgxInputFileModule {
41-
constructor(private repository: InputFileRepository) {
42-
repository.setOptions(options);
43-
}
44-
}
37+
export class MyModule {}
4538
```
4639
Import this module in your module.
4740

@@ -104,24 +97,29 @@ To add an other type, please open a issue.
10497
(removedFile)="onRemoveImage($event)">
10598
</input-file>
10699
```
107-
100+
Here's an example to post a file:
108101
```ts
109-
import { InputFileRepository } from 'ngx-input-file';
102+
import { HttpClient } from '@angular/common/http';
110103

111-
constructor(
112-
public inputFileRepository: InputFileRepository)
113-
{}
104+
@Injectable()
105+
export class MyRepository {
114106

115-
public post(file: any): Observable<Image> {
116-
const apiUrl = 'http://dumb.any/api/files';
117-
return this.inputFileRepository.post(file, apiUrl);
107+
constructor(
108+
private http: HttpClient
109+
) {}
110+
111+
public post(file: any): Observable<any> {
112+
const apiUrl = 'my-url';
113+
const formData = new FormData();
114+
formData.append('file', file.file, file.file.name);
115+
return this.http.post(apiUrl, formData)
116+
.map(res => <any>res);
118117
}
119118
```
120119
121120
## IMPORTANT!
122121
Icons is not packaged with the module.
123122
Default path of file icons is `assets/img` with the extension `.png`.
124-
Please use [@angular/cli](https://cli.angular.io/), `ng new ...` manages the folder `assets`.
125123
Any help is welcome to package icons or configure the path and extension.
126124
You can pick icons free [here](https://www.iconfinder.com/search?q=File&license=2&price=free).
127125

dist/README.md

+23-25
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
## Breaking changes
2+
Input file repository dropped.
3+
See below how to upload a file.
4+
15
# ngx-input-file
26

37
**ngx-input-file** is a module to replace the html element input file and also allows you to upload files.
48
Style is based on [Bootstrap File Input](http://plugins.krajee.com/file-input/demo).
5-
The component is compatible with [Bootstrap 4 beta](https://getbootstrap.com/).
9+
The component is compatible with [Bootstrap 4](https://getbootstrap.com/).
610

711
![Input File screenshot](http://img4.hostingpics.net/pics/626115inputfile1.png)
812

@@ -13,35 +17,24 @@ The component is compatible with [Bootstrap 4 beta](https://getbootstrap.com/).
1317
- Drag and drop zone
1418
- Responsive
1519
- [Font Awesome](http://fontawesome.io/) support
16-
- Uploads files with headers like `Authorization` (deprecated, other modules uploads files better than this one)
1720

1821
## Installation
1922
```bash
2023
npm install ngx-input-file --save
2124
```
2225

23-
## Basic Configuration (deprecated)
24-
The goal of this module is not to upload file but to provide a component to replace the html element input.
25-
Create a new `ngx-input-file.module.ts` file with the following code:
26-
```ts
26+
## Basic Configuration
27+
```typescript
2728
import { NgModule } from '@angular/core';
28-
import { InputFileModule, InputFileOptions, InputFileRepository } from 'ngx-input-file';
29+
import { InputFileModule } from 'ngx-input-file';
2930

30-
const options: InputFileOptions = new InputFileOptions(
31-
'auth-token-value',
32-
'Authorization'
33-
);
3431

3532
@NgModule({
3633
imports: [ InputFileModule ],
3734
exports: [ InputFileModule ]
3835
})
3936

40-
export class NgxInputFileModule {
41-
constructor(private repository: InputFileRepository) {
42-
repository.setOptions(options);
43-
}
44-
}
37+
export class MyModule {}
4538
```
4639
Import this module in your module.
4740

@@ -104,24 +97,29 @@ To add an other type, please open a issue.
10497
(removedFile)="onRemoveImage($event)">
10598
</input-file>
10699
```
107-
100+
Here's an example to post a file:
108101
```ts
109-
import { InputFileRepository } from 'ngx-input-file';
102+
import { HttpClient } from '@angular/common/http';
110103

111-
constructor(
112-
public inputFileRepository: InputFileRepository)
113-
{}
104+
@Injectable()
105+
export class MyRepository {
114106

115-
public post(file: any): Observable<Image> {
116-
const apiUrl = 'http://dumb.any/api/files';
117-
return this.inputFileRepository.post(file, apiUrl);
107+
constructor(
108+
private http: HttpClient
109+
) {}
110+
111+
public post(file: any): Observable<any> {
112+
const apiUrl = 'my-url';
113+
const formData = new FormData();
114+
formData.append('file', file.file, file.file.name);
115+
return this.http.post(apiUrl, formData)
116+
.map(res => <any>res);
118117
}
119118
```
120119
121120
## IMPORTANT!
122121
Icons is not packaged with the module.
123122
Default path of file icons is `assets/img` with the extension `.png`.
124-
Please use [@angular/cli](https://cli.angular.io/), `ng new ...` manages the folder `assets`.
125123
Any help is welcome to package icons or configure the path and extension.
126124
You can pick icons free [here](https://www.iconfinder.com/search?q=File&license=2&price=free).
127125

0 commit comments

Comments
 (0)