Add new components for AI and tutorials, update routing, and enhance file upload functionality
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {GlobalConstants} from '../global-constants';
|
||||
import {HttpClient, HttpEvent, HttpRequest} from '@angular/common/http';
|
||||
import {Observable} from 'rxjs';
|
||||
import {FileInfo} from '../models/file-info';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class FileUploadService {
|
||||
private baseUrl = GlobalConstants.API_URL + '/file';
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
upload(file: File): Observable<HttpEvent<any>> {
|
||||
const formData: FormData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
const req = new HttpRequest('POST', `${this.baseUrl}/upload`, formData, {
|
||||
responseType: 'json',
|
||||
});
|
||||
|
||||
return this.http.request(req);
|
||||
}
|
||||
|
||||
getFiles(): Observable<FileInfo[]> {
|
||||
return this.http.get<FileInfo[]>(`${this.baseUrl}/files`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user