public void uploadFile(string filename, int size) { Debug.Log("upload file start."); byte[] data = new byte[size]; StorageReference storageReference = mAGCStorageManagement.getStorageReference(filename); UploadTask task = storageReference.putBytes(data, new FileMetadata()); task.addOnFailureListener(new MyFailureListener()) .addOnSuccessListener(new MySuccessListener()) .addOnProgressListener(new MyProgressListener()) .addOnPausedListener(new MyPausedListener()); StorageTask.ErrorResult err = new MyErrorResult(); Exception e = err.getError(); task.setResult(err.obj); err = task.getResult(); if (err == null) { Debug.Log("uploadFileTest fail, getResult err is null."); return; } StorageTask.ErrorResult timePointState = task.getTimePointState(); if (timePointState == null) { Debug.Log("uploadFileTest fail, getTimePointState result is null."); return; } Exception exp = task.getException(); if (exp == null) { Debug.Log("uploadFileTest fail, getException result is null."); return; } task.setException(exp); AndroidJavaObject ajObj = task.getResultThrowException(new AndroidJavaClass("java.lang.Exception")); if (ajObj == null) { Debug.Log("uploadFileTest fail, getException result is null."); return; } Debug.Log("upload file test success."); }