2016-10-16 92 views
0

我在嘗試使用Firebase存儲更新文件的元數據時遇到此錯誤。使用Firebase存儲發送網絡請求PATCH時出錯

發送網絡請求錯誤PATCH https://firebasestorage.googleapis.com/v0/b/rootssahaj.appspot.com/o/notice%2Fthumbs java.net.ProtocolException:未知方法'PATCH';必須先[OPTIONS,GET,HEAD,POST,PUT,DELETE,TRACE]之一

10-16 12:31:04.819 2043-3160/com.rana.sahaj.myyu W/ExponenentialBackoff: network unavailable, sleeping. 
10-16 12:31:04.819 2043-3160/com.rana.sahaj.myyu W/NetworkRequest: error sending network request PATCH https://firebasestorage.googleapis.com/v0/b/rootssahaj.appspot.com/o/notice%2Fthumbs 
                   java.net.ProtocolException: Unknown method 'PATCH'; must be one of [OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE] 
                    at java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:685) 
                    at com.android.okhttp.internal.http.HttpsURLConnectionImpl.setRequestMethod(HttpsURLConnectionImpl.java:144) 
                    at brq.b(:com.google.android.gms.DynamiteModulesC:242) 
                    at brq.a(:com.google.android.gms.DynamiteModulesC:269) 
                    at brk.onTransact(:com.google.android.gms.DynamiteModulesC:53) 
                    at android.os.Binder.transact(Binder.java:361) 
                    at com.google.android.gms.internal.zzans$zza$zza.zzuj(Unknown Source) 
                    at com.google.android.gms.internal.zzanv.zza(Unknown Source) 
                    at com.google.android.gms.internal.zzanm.zza(Unknown Source) 
                    at com.google.android.gms.internal.zzanm.zzd(Unknown Source) 
                    at com.google.firebase.storage.zzf.run(Unknown Source) 
                    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
                    at  java.lang.Thread.run(Thread.java:841) 

用於更新元數據的代碼是:

FirebaseStorage storage = FirebaseStorage.getInstance(); 
    final StorageReference storageRefNonThumbs = storage.getReferenceFromUrl(constants.FIREBASE_STORAGE_URL + "/notice/nonThumbs"); 
    final StorageReference storageRefThumbs = storage.getReferenceFromUrl(constants.FIREBASE_STORAGE_URL + "/notice/thumbs"); 

    UploadTask uploadTaskThumb = storageRefThumbs.child(timestamp + EmailPref).putFile(DOCUri); 
    final StorageMetadata metadata = new StorageMetadata.Builder() 
      .setContentType(DocMiMEType) 
      .build(); 

storageRefThumbs.updateMetadata(metadata).addOnSuccessListener(new OnSuccessListener<StorageMetadata>() { 
     @Override 
     public void onSuccess(StorageMetadata storageMetadata) { 
      // Updated metadata is in storageMetadata 
      storageRefNonThumbs.updateMetadata(metadata) 
        .addOnSuccessListener(new OnSuccessListener<StorageMetadata>() { 
         @Override 
         public void onSuccess(StorageMetadata storageMetadata) { 
          // Updated metadata is in storageMetadata 
          // Uri downloadUrlNonThumb = taskSnapshot.getDownloadUrl(); 

          // saveData(editText, null, downloadUrlThumb.toString(), mTime, timestamp, null, null, null, downloadUrlNonThumb.toString()); 
          Log.e("SahajLOG98", "Success in [email protected]@22***"); 
         } 
        }) 
        .addOnFailureListener(new OnFailureListener() { 
         @Override 
         public void onFailure(@NonNull Exception exception) { 
          // Uh-oh, an error occurred! 
         } 
        }); 
     } 
    }) 

回答

0

這是一個已知問題的Android版本< = 4.0(冰淇淋三明治及以下)和Firebase存儲。未來版本的SDK中會出現一個修復程序。

相關問題