-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(input): added the ability to pass a beforeUpload function that c…
- Loading branch information
Showing
9 changed files
with
68 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
<h4 class="mb-3">Limit and filter images</h4> | ||
<h4 class="mb-3 mt-5">Limit and filter images</h4> | ||
|
||
<image-upload url="https://httpbin.org/status/200" [max]="2" [extensions]="['jpeg','png']"></image-upload> | ||
|
||
<pre><code class="language-markup"><![CDATA[<image-upload url="https://httpbin.org/status/200" [max]="2" [extensions]="['jpeg','png']"></image-upload>]]></code></pre> | ||
|
||
<h5 class="mb-3 mt-3">Manual filtering and editing</h5> | ||
|
||
<image-upload url="https://httpbin.org/status/200" [beforeUpload]="onBeforeUpload"></image-upload> | ||
|
||
<pre><code class="language-markup"><![CDATA[<image-upload url="https://httpbin.org/status/200" [beforeUpload]="onBeforeUpload"></image-upload>]]></code></pre> | ||
|
||
<pre><code class="language-typescript"><![CDATA[private fileCounter = 0; | ||
|
||
onBeforeUpload = (metadata: UploadMetadata) => { | ||
if (this.fileCounter % 2 === 0) { | ||
metadata.abort = true; | ||
} else { | ||
// mutate the file or replace it entirely - metadata.file | ||
metadata.url = 'http://somewhereelse.com' | ||
} | ||
|
||
this.fileCounter++; | ||
return metadata; | ||
};]]></code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
import { Component } from '@angular/core'; | ||
import { UploadMetadata } from '../../lib/image-upload/before-upload.interface'; | ||
|
||
@Component({ | ||
selector: 'filter', | ||
templateUrl: './filter.component.html' | ||
}) | ||
export class FilterExampleComponent { | ||
private fileCounter = 0; | ||
|
||
onBeforeUpload = (metadata: UploadMetadata) => { | ||
if (this.fileCounter % 2 === 0) { | ||
metadata.abort = true; | ||
} else { | ||
// mutate the file or replace it entirely - metadata.file | ||
metadata.url = 'http://somewhereelse.com'; | ||
} | ||
|
||
this.fileCounter++; | ||
return metadata; | ||
}; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { ImageUploadModule } from './lib/image-upload.module'; | ||
export { ImageUploadComponent, FileHolder } from './lib/image-upload/image-upload.component'; | ||
export { UploadMetadata } from './lib/image-upload/before-upload.interface'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface UploadMetadata { | ||
file: File; | ||
url: string; | ||
abort: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters