在firebase存储中,我需要在保存之前发送两次照片

时间:2018-06-17 15:09:19

标签: java android firebase firebase-storage

(对不起我的英文)(对不起,如果这个问题无关紧要,我是编程的新手)所以我正在制作一个聊天应用程序但是当我尝试发送照片时它不发送,只有我发送它两次它在db中保存。

以下是我在logcat中收到的警告:

06-17 17:12:27.685 927-1000/? E/WifiConfigStore: updateConfiguration freq=2442 BSSID=f4:f2:6d:67:54:e8 RSSI=-59 "TP-LINK_54E8"WPA_PSK06-17 17:12:27.831 10830-11008/com.google.firebase.udacity.friendlychat E/StorageException: StorageException has occurred.
Object does not exist at location.
 Code: -13010 HttpResult: 404
{  "error": {    "code": 404,    "message": "Not Found.  Could not get object"  }}
java.io.IOException: {  "error": {    "code": 404,    "message": "Not Found.  Could not get object"  }}
    at bha.a(:com.google.android.gms.dynamite_dynamitemodulesc@12685024@12.6.85 (040406-197041431):147)
    at bha.a(:com.google.android.gms.dynamite_dynamitemodulesc@12685024@12.6.85 (040406-197041431):119)
    at bgu.onTransact(:com.google.android.gms.dynamite_dynamitemodulesc@12685024@12.6.85 (040406-197041431):7)
    at android.os.Binder.transact(Binder.java:392)
    at com.google.android.gms.internal.firebase_storage.zza.transactAndReadExceptionReturnVoid(Unknown Source)
    at com.google.android.gms.internal.firebase_storage.zzm.zze(Unknown Source)
    at com.google.android.gms.internal.firebase_storage.zzq.zza(Unknown Source)
    at com.google.android.gms.internal.firebase_storage.zzf.zza(Unknown Source)
    at com.google.firebase.storage.zzc.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:818)06-17 17:12:28.091 927-927/? E/WifiTrafficPoller: TRAFFIC_STATS_POLL true Token 1236 num clients 10
 packet count Tx=1047457 Rx=3285705 06-17 17:12:29.092 927-927/? E/WifiTrafficPoller: TRAFFIC_STATS_POLL true Token 1236 num clients 10
 packet count Tx=1047458 Rx=3285706

这是代码:

protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == RC_PHOTO_PICKER && resultCode == RESULT_OK) 
    {
        Uri selectedImageUri = data.getData();
        StorageReference photoRef = mSRreference.child(selectedImageUri.toString());
        photoRef.putFile(selectedImageUri);
        photoRef.getDownloadUrl().addOnSuccessListener(
            new OnSuccessListener<Uri>()

            @Override
            public void onSuccess(Uri uri)
            {
                Message m = new Message(null, mUsername, uri.toString());
                mDbReference.push().setValue(m);
            }
        );
    }
}

这里

2 个答案:

答案 0 :(得分:0)

this Article返回putFile(),最终表明该文件已成功上传。您需要使用该任务。您似乎已经熟悉了任务,因为您已经使用getDownloadUrl()返回的任务来确定该数据何时可用。

答案 1 :(得分:0)

fabs

这将完成你的工作。