0

I didn't find this in the documentation of Angular and RxJS. Is there any way to fetch a MediaType (img, video ..) data from an HTTP response an process/download it ?

The problem is that whether with the get or head HTTP method with an image (png) or an XML media type from the backend, I keep having the following HTTP error :

415 Unsupported Media Type

Here is the code, Version 1:

 return this.http.head(this.localBackURL + ressourcesPath.exportStatistiques, {search: params}); 

Version 2 :

 return this.http.head(this.localBackURL + ressourcesPath.exportStatistiques, {search: params}); 

Thanks

Ismail H
  • 4,226
  • 2
  • 38
  • 61
  • You can probably head and parse the headers from response. – Shurik Agulyansky Jan 12 '17 at 10:19
  • Can you give information about the MediaType? Also, maybe some code would help to solve the problem – Loki Jan 12 '17 at 10:28
  • Can you please provide some code? The method to download the file, in which the error probably occurs, would be nice. – Loki Jan 12 '17 at 10:41
  • Hello, and thanks for your time. I added the return method. There is nothing special other. the parameters can be deleted with the same result – Ismail H Jan 12 '17 at 10:48
  • It looks like both code lines are the same. Do you have any settings on the request? Like where you set Headers or something? Please take a look at the updated answer and the link provided there. – Loki Jan 12 '17 at 10:49

1 Answers1

0

I'm not really sure if I understood the problem correctly.

But to get metadata from something, instead of using the get request method, you can use the head request method.

You can probably use this to get the information needed to decide if you want to proceed with the get method afterwards.

If you just want to download the file and then check for the MediaType you can read the headers after getting the file.

Update A quick google to the Error and I found the following. As there is currently no code for me to look at, I assume you'll probably have similar issues as I found.

415 Unsupported Media Type - POST json to OData service in lightswitch 2012

It looks like this Error happens if you have wrong Content-Type and/or wrong Accept Header settings.

Community
  • 1
  • 1
Loki
  • 4,065
  • 4
  • 29
  • 51