Firebase storage upload successful upload but upload size on Firebase console is 0B
<p>I am having a weird problem with Firebase storage. Recently, I was able to upload files perfectly. But now, the upload seems to fire onSuccess even if the upload is not yet complete. The upload shows 0B on the console and the file extension is application/octet-stream. I am uploading the same image that I was able to upload before and I did not make changes to my code. </p>

<p>Here's my code</p>

<pre><code>@Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == PICK_IMAGE) {
            if (data == null) {
                //Display an error
                return;
            }
            try {
                //UPLOAD IMAGE
                InputStream inputStream = getActivity().getContentResolver().openInputStream(data.getData());
                if(inputStream != null) {
                    img_upload_school_pic.setImageBitmap(BitmapFactory.decodeStream(new BufferedInputStream(inputStream)));
                    img_upload_school_pic.setVisibility(View.INVISIBLE);
                    //SHOW PROGRESSBAR
                    prg_upload.setVisibility(View.VISIBLE);
                    //UPLOAD IMAGE
                    ImageUploader uploader = new ImageUploader();
                    uploader.uploadSchoolDp(inputStream, "sample.jpg", img_upload_school_pic, prg_upload);
                }
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
    }
</code></pre>

<p>The code for the uploader class</p>

<pre><code>public class ImageUploader {

    private StorageReference rootRef = FirebaseStorage.getInstance().getReference().getRoot();

    public void uploadSchoolDp(final InputStream inputStream, String key,
                               final ImageView img_upload_school_pic, final ProgressBar prg_upload) {

        StorageReference schools_dp_ref = rootRef.child("samplefoler");

        StorageReference img_df_ref = schools_dp_ref.child(key);

        UploadTask uploadTask = img_df_ref.putStream(inputStream);

        uploadTask.addOnSuccessListener(new OnSuccessListener&lt;UploadTask.TaskSnapshot&gt;() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                //HIDE PROGRESSBAR AND SHOW IMAGEVIEW
                img_upload_school_pic.setVisibility(View.VISIBLE);
                prg_upload.setVisibility(View.INVISIBLE);
            }
        });

        uploadTask.addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                e.printStackTrace();
            }
        });
//
//        uploadTask.addOnProgressListener(new OnProgressListener&lt;UploadTask.TaskSnapshot&gt;() {
//            @Override
//            public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
//                txt_progress.setText(taskSnapshot.getBytesTransferred() + " of " +
//                        taskSnapshot.getTotalByteCount());
//                Log.d(null, Double.toString(taskSnapshot.getTotalByteCount()));
//            }
//        });

    }
}
</code></pre>

<p>And there's one more thing. taskSnapshot.getTotalByteCount() returns -1. I can't use it to show the status of the upload so I just comment it out for the moment. </p>