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 {
1717
1818    fileName  =  '' ; 
1919
20+     fileUploadError  =  false ; 
21+ 
22+     constructor ( private  http : HttpClient )  { 
23+ 
24+     } 
25+ 
2026    onFileSelected ( event )  { 
2127
2228        const  file :File  =  event . target . files [ 0 ] ; 
@@ -25,10 +31,37 @@ export class FileUploadComponent {
2531
2632            this . fileName  =  file . name ; 
2733
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+ 
2950
3051        } 
3152
3253    } 
3354
3455} 
56+ 
57+ 
58+ 
59+ 
60+ 
61+ 
62+ 
63+ 
64+ 
65+ 
66+ 
67+ 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments