You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
argos/dmp-frontend/src/app/services/files/project-file-uploader.servi...

31 lines
1.0 KiB
TypeScript

import { HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import 'rxjs/add/operator/map';
import { environment } from '../../../environments/environment';
import { ContentFile } from '../../models/files/ContentFile';
import { FileUploader } from '../../shared/components/file-uploader/FileUploader';
import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service';
@Injectable()
export class ProjectFileUploaderService implements FileUploader {
private actionUrl: string;
private headers: HttpHeaders;
constructor(private http: BaseHttpService) {
this.actionUrl = environment.Server + 'files/';
this.headers = new HttpHeaders();
this.headers = this.headers.set('Content-Type', 'application/json');
this.headers = this.headers.set('Accept', 'application/json');
}
uploadFile(formData: FormData): Observable<ContentFile> {
return this.http.post(this.actionUrl + 'upload', formData, this.headers);
}
}