title: Ionic 2 Angular 2 HTTP Post Base64 Image to Server results in sanitizing unsafe URL before sending
body: <p>I am using the Ionic Native Camera plugin to take a picture and save it in base64. </p>
  
  <p>Then I want to send that image to Amazon s3 to store. </p>
  
  <p>I send a package via POST to my API containing the base64 image, bucketname, keyname, etc.</p>
  
  <p>Before http sends the data to my server I get a warning in my console saying: "WARNING: sanitizing unsafe URL value data:image/jpeg;base64" </p>
  
  <p>I did some research and found that Angular sanitizes urls because they might contain XSS that could be harmful to the recipient. </p>
  
  <p>Since I know my URLs will be clean, I imported DomSanitizer and used "bypassSecurityTrustUrl" on the image before sending. </p>
  
  <p>I am still getting the same error message as before. </p>
  
  <p>Is there anyway to disable this for outbound HTTP posts? I would still like to keep it for incoming data. </p>
  
  <p>Here is image service code...</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { Http, Response } from '@angular/http';
  import { DomSanitizer } from '@angular/platform-browser';
  
  
  @Injectable()
  export class ImageService {
  
      constructor(
          private http: Http,
          private sanitizer: DomSanitizer
          ) {}
  
      uploadProfileImage(userInfo, image) {
  
          return new Promise(resolve =&gt; {
          let pkg = {
              image: this.sanitizer.bypassSecurityTrustUrl(image),
              name: userInfo.uid,
              folder: 'profileImages',
              email: userInfo.email
          }
  
          console.log('pkg upload profile image', JSON.stringify(pkg));
          this.http.post('https://myurl/api/uploadpicture', pkg)
             .subscribe( res =&gt; console.log('response from upload picture', JSON.stringify(res)));
  
          })
      }
  
  }
  </code></pre>
  
  <p>When I console log 'pkg upload profile image', the image value looks like this 
  <code>{"image":{"changingThisBreaksApplicationSecurity":"data:image/jpeg;base64,file:///var/mobile/Containers/Data/Application/xxxxxxxxxx/tmp/cdv_photo_007.jpg"},</code> </p>
  
  <p>My response from Amazon S3 is fine, a file is posted in the correct bucket with the correct key name, but the image is corrupted and only ~80 bytes. </p>
  
  <p>I would really appreciate some help, this was working fine on my Ionic 1 app using Angular 1.x. </p>
  
  <p>Thanks</p>