无法在Firebase中上传视频

时间:2019-04-05 08:06:22

标签: firebase video firebase-realtime-database android-videoview

我正在尝试将视频上传到Firebase,但无法执行。我可以录制视频,但是无法上传。     消息弹出窗口“ Nothing to Upload”,我不知道我在做什么错。

 public void upload(View view){
        if (videoUri!=null){
            UploadTask uploadTask=videoRef.putFile(videoUri);

            uploadTask.addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {

                    Toast.makeText(MainActivity.this, "Upload Failed: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
                }
            }).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                @Override
                public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                    Toast.makeText(MainActivity.this, "Upload Complete", Toast.LENGTH_LONG).show();
                }
            }).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
                @Override
                public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
                    updateProgress(taskSnapshot);
                }
            });
        }
        else {
            Toast.makeText(MainActivity.this, "Nothing to upload ", Toast.LENGTH_LONG).show();
        }
    }

0 个答案:

没有答案