Skip to content

Conversation

Birot
Copy link
Contributor

@Birot Birot commented Sep 4, 2017

Hello,

To download a file, the responseType is being ignored. Thererfore the responded data is handled as a String, with the normal JSON parsing. In a response with blob data I get an error because it is trying to parse the data as JSON. In adding the responseType
in the createRequestOptions method of RestangularHelper :
let requestOptions = new RequestOptions({ method: RequestMethod[methodName], headers: requestHeaders, search: requestQueryParams, url: options.url, body: options.data, responseType: options.responseType, withCredentials });
the bug is fixed. We just need to set the reponseType of a request like this :
this.restangular.oneUrl('file/').withHttpConfig({responseType: ResponseContentType.Blob}).get( ) .subscribe(data => { this.downloadFileInternal(data) });

Hello, To download a file, the responseType is being ignored. Thererfore the responded data is handled as a String, with the normal JSON parsing. In a response with blob data I get an error because it is trying to parse the data as JSON. In adding the responseType in the createRequestOptions method of RestangularHelper : ``` let requestOptions = new RequestOptions({ method: RequestMethod[methodName], headers: requestHeaders, search: requestQueryParams, url: options.url, body: options.data, responseType: options.responseType, withCredentials }); ``` the bug is fixed. We just need to set the reponseType of a request like this : ``` this.restangular.oneUrl('file/').withHttpConfig({responseType: ResponseContentType.Blob}).get( ) .subscribe(data => { this.downloadFileInternal(data) }); ```
@rshchpkn rshchpkn merged commit a0a6fd3 into 2muchcoffeecom:master Oct 9, 2017
@Birot Birot deleted the patch-1 branch October 10, 2017 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants