Add file upload functionality with dialog components and update image handling
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { FileUploadApiService } from './file-upload-api.service';
|
||||
|
||||
describe('FileUploadApiService', () => {
|
||||
let service: FileUploadApiService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(FileUploadApiService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,29 +0,0 @@
|
||||
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