title: How to upload pictures to firebase in Ionic 4?
body: <p>I'm unable to upload images to firebase.  Any help would be appreciated.</p>
  
  <p>Is anyone familiar with how to upload pictures to firebase in Ionic 4.0?  Below is the code that use to work in Ionic 2, but now when I click the button to upload an image to firebase it takes approximately 30 seconds to respond to the (click) and then it never uploads the image to firebase.</p>
  
  <p>I tried using the example in this tutorial but I can't get rid of the errors related to ImagePicker.  <a href="https://ionicthemes.com/tutorials/about/ionic-firebase-image-upload" rel="nofollow noreferrer">https://ionicthemes.com/tutorials/about/ionic-firebase-image-upload</a>
  Any help would be greatly appreciated.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>      &lt;ion-card-content&gt;
              &lt;div&gt;
                  &lt;img src="assets/img/add-an-image.png" (click)="selectPhoto()"/&gt;     
              &lt;/div&gt;
          &lt;/ion-card-content&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>constructor(
      private afAuth: AngularFireAuth,
      private camera: Camera) {
  
          this.afAuth.authState.subscribe(user =&gt; {
          this.userId = user.uid;
          this.myPhotosRef = firebase.storage().ref(`/Photos/${ this.userId }/`);
        });
      }
  
    selectPhoto(): void {
      const options: CameraOptions = {
        quality: 100,
        destinationType: this.camera.DestinationType.FILE_URI,
        encodingType: this.camera.EncodingType.JPEG,
        mediaType: this.camera.MediaType.PICTURE,
        sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
      };
  
      this.camera.getPicture(options).then((imageData) =&gt; {
        console.log(options, 'get pic');
        this.myPhoto = imageData;
        this.uploadPhoto(this.myPhoto);
      }, error =&gt; {
        console.log('ERROR -&gt; ' + JSON.stringify(error));
      });
    }
  
    private uploadPhoto(photoName: string): void {
      this.myPhotosRef.child(photoName)
        .putString(this.myPhoto, 'base64', { contentType: 'image/png' })
        .then((savedPicture) =&gt; {
          this.myPhotoURL = savedPicture.downloadURL;
        });
    }</code></pre>
  </div>
  </div>
  </p>