[Trunk | Library]: reports.service: Fix requests for csv files.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@56115 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
025de02c2f
commit
fc58f9ac80
|
@ -11,20 +11,24 @@ import {map, tap} from "rxjs/operators";
|
||||||
export class ReportsService {
|
export class ReportsService {
|
||||||
// url:string = "http://beta.services.openaire.eu:8480/search/rest/v2/api/publications?format=csv&page=0&size=3&q=(%22test%22)&fq=instancetypename%20exact%20%22Dataset%22";
|
// url:string = "http://beta.services.openaire.eu:8480/search/rest/v2/api/publications?format=csv&page=0&size=3&q=(%22test%22)&fq=instancetypename%20exact%20%22Dataset%22";
|
||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
//text/html
|
|
||||||
//On the service:
|
//On the service:
|
||||||
downloadCSVFile(url: string){
|
downloadCSVFile(url: string){
|
||||||
//var headers = new Headers();
|
//var headers = new Headers();
|
||||||
//headers.append('responseType', 'arraybuffer');
|
//headers.append('responseType', 'arraybuffer');
|
||||||
return this.http.get(url)
|
return this.http.get(url, {responseType: 'text'})
|
||||||
.pipe(map(res => new Blob([res['_body']], { type: 'text/csv' })));
|
.pipe(map(res => new Blob([res], { type: 'text/csv' })));
|
||||||
}
|
}
|
||||||
getCSVResponse(url: string){
|
getCSVResponse(url: string){
|
||||||
//var headers = new Headers();
|
//var headers = new Headers();
|
||||||
//headers.append('responseType', 'arraybuffer');
|
//headers.append('responseType', 'arraybuffer');
|
||||||
return this.http.get(url)
|
return this.http.get(url, {responseType: 'text'});
|
||||||
.pipe(map(res => res['_body']));
|
//.pipe(map(res => res));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated not used
|
||||||
|
*/
|
||||||
downloadHTMLFile(url: string, info: string){
|
downloadHTMLFile(url: string, info: string){
|
||||||
//var headers = new Headers();
|
//var headers = new Headers();
|
||||||
//headers.append('responseType', 'arraybuffer');
|
//headers.append('responseType', 'arraybuffer');
|
||||||
|
@ -34,6 +38,9 @@ export class ReportsService {
|
||||||
.pipe(tap(res => console.log(res)))
|
.pipe(tap(res => console.log(res)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated not used
|
||||||
|
*/
|
||||||
addInfo(res:any, info:string) {
|
addInfo(res:any, info:string) {
|
||||||
/*
|
/*
|
||||||
var para = res.document.createElement("P"); // Create a <p> element
|
var para = res.document.createElement("P"); // Create a <p> element
|
||||||
|
|
Loading…
Reference in New Issue