Firebase获取https://下载URL而不是gs://

时间:2018-10-05 05:52:07

标签: java android firebase firebase-storage

我已经尝试过解决this问题,但是它只返回gs://链接。

final StorageReference ref = storageReference.child("images/"+ UUID.randomUUID().toString());

        ref.putFile(filePath)
                .addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {

                    @Override

                    public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                        Log.d("DOWNLOAD URL", getRef(ref.getDownloadUrl().toString()));
                        progressDialog.dismiss();
                        Toast.makeText(ChatActivity.this, "Uploaded", Toast.LENGTH_SHORT).show();

                    }
                })

private String getRef (String name){
    // Points to the root reference
    StorageReference storageRef = FirebaseStorage.getInstance().getReference();
    StorageReference dateRef = storageRef.child("images/" + name);
    return dateRef.toString();
}

日志显示:D/DOWNLOAD URL: gs://app.appspot.com/images/com.google.android.gms.tasks.zzu%40dccce

我似乎无法找到将其变成可用的https://链接的任何内容,例如https://firebasestorage.googleapis.com/v0/b/chat.appspot.com/o/images%2F06fe85b3-ff6f-4dd9-a3f2-88e2727f87a7?alt=media&token=f9a5e5fb-d494-426f-9ca5-1a

0 个答案:

没有答案