我得到一个简单的示例rom firebase如何将upload图像存储起来。上传很好,当Jul 17 17:15:48.699 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Jul 17 17:15:48.700 [notice] Read configuration file "/usr/local/etc/tor/torrc".
Jul 17 17:15:48.704 [notice] Opening Socks listener on 127.0.0.1:9050
Jul 17 17:15:48.704 [warn] Could not bind to 127.0.0.1:9050: Address already in use. Is Tor already running?
Jul 17 17:15:48.704 [notice] Opening Control listener on 127.0.0.1:9051
Jul 17 17:15:48.704 [notice] Closing partially-constructed Control listener on 127.0.0.1:9051
Jul 17 17:15:48.705 [warn] Failed to parse/validate config: Failed to bind one of the listener ports.
Jul 17 17:15:48.705 [err] Reading config failed--see warnings above.
我有uri下载这样的东西时:
onSucess
当我尝试将此uri转换为字符串时我有https://firebasestorage.googleapis.com/v0/b/sexstartup-e3a65.appspot.com/o/User%3A%20epAPhTPZtUQwNprZpUIKOOc4DJk2%2Fimg.jpg?alt=media&token=49a479c2-fdfa-42ec-9376-278fca3b73e3
,这是错误的吗?
Nullpointerexception
答案 0 :(得分:1)
您需要通过调用getDownloadUrl()
对象(而不是taskSnapshot
)上的方法getMetadata()
来更改代码 - 因此onSuccess
回调中的代码应如下所示:
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
//get the download URL like this:
Uri downloadUrl = taskSnapshot.getDownloadUrl();
//and you can convert it to string like this:
String string_dwload = downloadUrl.toString();
}
我希望这会有所帮助。顺便说一句,请查看Uploading file on Android
上的文章/教程