Last change
on this file 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 | |
---|
1 | import {Injectable} from '@angular/core';
|
---|
2 | import {HttpClient, HttpEvent} from "@angular/common/http";
|
---|
3 | import {Observable} from "rxjs";
|
---|
4 |
|
---|
5 | @Injectable({
|
---|
6 | providedIn: 'root'
|
---|
7 | })
|
---|
8 | export 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.