Add file upload functionality with dialog components and update image handling
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {forkJoin, Observable} from 'rxjs';
|
||||
import {Tutorial} from '../../models/tutorial.model';
|
||||
import {HttpClient, HttpHeaders} from '@angular/common/http';
|
||||
import {HttpClient, HttpEvent, HttpHeaders, HttpRequest} from '@angular/common/http';
|
||||
import {GlobalConstants} from '../../global-constants';
|
||||
import {FileInfo} from '../../models/file-info';
|
||||
|
||||
@@ -15,6 +15,19 @@ export class UserApiService {
|
||||
|
||||
}
|
||||
|
||||
upload(file: File): Observable<HttpEvent<any>> {
|
||||
const formData: FormData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
const req = new HttpRequest('POST', `${this.baseUrl}/upload`, formData, {
|
||||
reportProgress: true,
|
||||
responseType: 'json'
|
||||
});
|
||||
|
||||
return this.http.request(req);
|
||||
}
|
||||
|
||||
|
||||
saveZhipuaiImage(url: string): Observable<any> {
|
||||
return this.http.post(`${this.baseUrl}/saveZhipuAiImage`, {imageUrl:url});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user