Created
August 12, 2018 13:38
-
-
Save aarivalagan/8bfbe47ef8cf0dac267374a8f0ef5b0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { HttpClient } from '@angular/common/http'; | |
import { AngularFireDatabase, AngularFireList } from 'angularfire2/database'; | |
import { Observable } from 'rxjs/Observable'; | |
import 'rxjs/add/operator/catch'; | |
import { catchError } from 'rxjs/operators'; | |
@Injectable() | |
export class VDataService { | |
constructor(private db: AngularFireDatabase, | |
private http: HttpClient) { } | |
vList: AngularFireList<any>; | |
//url: string; | |
request_options: string; | |
getVideoData(): any { | |
this.vList = this.db.list('/newCour'); | |
return this.vList; | |
} | |
UpdateVideoList($key: string, flag: boolean) { | |
this.vList.update($key, { Completed: flag }); | |
} | |
uploadFile(file) { | |
let formData: FormData = new FormData(); | |
formData.append('file', file, file.name); | |
this.http.post("http://localhost:/4200/", formData) | |
} | |
postFile(fileToUpload: File): Observable<boolean> { | |
const endpoint = 'your-destination-url'; | |
const formData: FormData = new FormData(); | |
formData.append('fileKey', fileToUpload, fileToUpload.name); | |
return this.http | |
.post(endpoint, formData, { headers: this.yourHeadersConfig }) | |
.map(() => { return true; }) | |
.catchError((e) => this.handleError(e)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment