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."); }
public void timePointStateBaseTest() { byte[] data = new byte[100]; string filename = "timePointStateBaseTest.data"; StorageReference storageReference = mAGCStorageManagement.getStorageReference(filename); UploadTask task = storageReference.putBytes(data, new FileMetadata()); StorageTask.ErrorResult err = task.getTimePointState(); StorageTask.TimePointStateBase timePoint = HmsUtil.GetHmsBase <StorageTask.TimePointStateBase>(err.obj); Exception e = timePoint.getError(); if (e == null) { Debug.Log("timePointStateBaseTest fail, error result is null"); return; } StorageReference timeRef = timePoint.getStorage(); if (timeRef == null) { Debug.Log("timePointStateBaseTest fail, timeRef is null"); return; } StorageTask storageTask = timePoint.getTask(); if (storageTask == null) { Debug.Log("timePointStateBaseTest fail, storageTask is null"); return; } Debug.Log("timePointStateBaseTest success"); }