source: Sources/frontend/src/app/materials.service.ts@ 0e4e3d1

Last change on this file since 0e4e3d1 was 8423429, checked in by AngelNasev <angel.nasev@…>, 17 months ago

Add backend and frontend projects

  • Property mode set to 100644
File size: 873 bytes
Line 
1import {Injectable} from '@angular/core';
2import {HttpClient, HttpEvent} from "@angular/common/http";
3import {Observable} from "rxjs";
4
5@Injectable({
6 providedIn: 'root'
7})
8export class MaterialsService {
9 private path = 'http://localhost:8080/api/materials'
10
11 constructor(private http: HttpClient) {
12 }
13
14 upload(formData: FormData, username: string, courseId: number): Observable<HttpEvent<string[]>> {
15 return this.http.post<string[]>(`${this.path}/upload/${courseId}`, formData, {
16 reportProgress: true,
17 observe: 'events'
18 });
19 }
20
21 download(filename: string): Observable<HttpEvent<Blob>> {
22 return this.http.get(`${this.path}/download/${filename}`, {
23 reportProgress: true,
24 observe: 'events',
25 responseType: 'blob'
26 });
27 }
28
29 findAllMaterialsForCourse(id : number){
30 return this.http.get(`${this.path}/all/${id}`)
31 }
32}
Note: See TracBrowser for help on using the repository browser.