seattle-java-401d1

CF Firebase Auth and Storage

Resources

Learning Objectives

Lecture Outline

Code Samples

Uploading an image to Firebase Storage:

private void upload() {
  Uri file = Uri.fromFile(new File("path/to/images/rivers.jpg"));
  StorageReference riversRef = mStorageRef.child("images/rivers.jpg");

  riversRef.putFile(file)
  .addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
      @Override
      public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
          // Get a URL to the uploaded content
          Uri downloadUrl = taskSnapshot.getDownloadUrl();
      }
  })
  .addOnFailureListener(new OnFailureListener() {
      @Override
      public void onFailure(@NonNull Exception exception) {
          // Handle unsuccessful uploads
          // ...
      }
  });
}