title: How to add an image to a record in a Firestore database
body: <p>I need to add JPEG images to Firestore DB records. My preferred way would be in a blob as I have used in SQLite records. I ran into some problems trying this.</p>
  <p>This is my best try so far:</p>
  <pre><code>public Blob getImage() {
      Uri uri = Uri.fromFile(new
  File(mCurrentPhotoPath));
      File f1 = new File(mCurrentPhotoPath);
      URL myURL = null;
      try {
  
          myURL = f1.toURI().toURL();
      } catch (MalformedURLException e) {
          e.printStackTrace();
      }
  
      Bitmap bitmap = null;
  
      BitmapFactory.Options options = new
  BitmapFactory.Options();
      options.inPreferredConfig =
  Bitmap.Config.ARGB_8888;
      try {
          if (myURL != null) {
              bitmap =
  BitmapFactory.decodeStream(
  myURL.openConnection().getInputStream());
              String wBlob =
  encodeToBase64(bitmap,
   Bitmap.CompressFormat.JPEG, 100);
         blob = fromBase64String(wBlob);
  }
  
  
      } catch (java.io.IOException e) {
          e.printStackTrace();
  
      }
      return blob;
  }
  </code></pre>
  <p>My problem is in the line:</p>
  <pre><code>blob = fromBase64String(wBlob);
  </code></pre>
  <p>I also have a problem with passing a blob to the class that sets the record:</p>
  <pre><code>intent.putExtra(&quot;blobImage&quot;,  blob );
  </code></pre>