使用Firebase存储发送网络请求PATCH时出错

时间:2016-10-16 07:09:59

标签: android firebase firebase-storage

尝试使用Firebase存储更新文件的元数据时出现此错误。

错误发送网络请求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 MEtaData@@22***");
                        }
                    })
                    .addOnFailureListener(new OnFailureListener() {
                        @Override
                        public void onFailure(@NonNull Exception exception) {
                            // Uh-oh, an error occurred!
                        }
                    });
        }
    })

1 个答案:

答案 0 :(得分:0)

这是Android版本&lt; = 4.0(冰淇淋三明治及以下)和Firebase存储的已知问题。 SDK的未来版本将出现修复。