File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,12 @@ export class FileUploadComponent {
17
17
18
18
fileName = '' ;
19
19
20
+ fileUploadError = false ;
21
+
22
+ constructor ( private http : HttpClient ) {
23
+
24
+ }
25
+
20
26
onFileSelected ( event ) {
21
27
22
28
const file :File = event . target . files [ 0 ] ;
@@ -25,10 +31,37 @@ export class FileUploadComponent {
25
31
26
32
this . fileName = file . name ;
27
33
28
- console . log ( this . fileName ) ;
34
+ const formData = new FormData ( ) ;
35
+
36
+ formData . append ( "thumbnail" , file ) ;
37
+
38
+ this . fileUploadError = false ;
39
+
40
+ this . http . post ( "/api/thumbnail-upload" , formData )
41
+ . pipe (
42
+ catchError ( error => {
43
+ this . fileUploadError = true ;
44
+ return of ( error ) ;
45
+ } )
46
+ )
47
+ . subscribe ( ) ;
48
+
49
+
29
50
30
51
}
31
52
32
53
}
33
54
34
55
}
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
You can’t perform that action at this time.
0 commit comments