taskSnapshot.getDownloadUrl()的替代方法

时间:2018-11-27 07:41:26

标签: android firebase

我正在尝试上载Pdf文件,但是由于getDownloadUrl()出现错误 现在折旧了。

我应该使用什么来使其正常工作?

private void uploadFile(Uri data) {
    progressBar.setVisibility(View.VISIBLE);
    StorageReference sRef = mStorageReference.child(constants.STORAGE_PATH_UPLOADS + System.currentTimeMillis() + ".pdf");
    sRef.putFile(data)
            .addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
                @SuppressWarnings("VisibleForTests")
                @Override
                public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                    progressBar.setVisibility(View.GONE);
                    textViewStatus.setText("File Uploaded Successfully");
                    uploads upload = new uploads(editTextFilename.getText().toString(), taskSnapshot.getDownloadUrl().toString());
                    mDatabaseReference.child(mDatabaseReference.push().getKey()).setValue(upload);
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception exception) {
                    Toast.makeText(getApplicationContext(), exception.getMessage(), Toast.LENGTH_LONG).show();
                }
            })

0 个答案:

没有答案