0

Is there a way for an interceptor to convert a base64 image to multipart/form-data? I have an external component that converts uploads to base64 and the sends it to a local API. Latest requirements state that I should send it as a multipart/form-data. Giving the fact that I cannot request that from that external component, can I achieve that locally with angular interceptors?

Iulian Miu
  • 218
  • 2
  • 8

2 Answers2

0

using pipe() will do the work.

see this article:

https://indepth.dev/posts/1051/top-10-ways-to-use-interceptors-in-angular

Mahdi Zarei
  • 5,644
  • 7
  • 24
  • 54
0

You might be lucky if the external component is an Angular library style component, and uses Angular's HttpClient API. If that's the case, then I believe that the HttpInterceptor interface will allow you to access the component's requests.

Otherwise, if the external component is using XMLHttpRequest you could intercept its calls by overriding the XMLHttpRequest.open method like this :

Override XMLHttpRequest

ktsangop
  • 1,013
  • 2
  • 16
  • 29