Firebase存储10.2.6->无法打开结果流 [英] Firebase Storage 10.2.6 -> Could not open resulting stream

查看:69
本文介绍了Firebase存储10.2.6->无法打开结果流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拥有新的Firebase Storage SDK(即10.2.6)并遇到了问题.当我尝试下载文件时,出现此错误.以前在10.2.1中我没有问题.

I have and issue with the new Firebase Storage SDK, namely 10.2.6. When I try do download a file I get this error. Previously in the 10.2.1 I had no problem.

I/DynamiteModule: Considering local module com.google.android.gms.firebasestorage:0 and remote module com.google.android.gms.firebasestorage:6
I/DynamiteModule: Selected remote version of com.google.android.gms.firebasestorage, version >= 6
V/FA: Activity resumed, time: 148646549
D/debugStorageListener: onSuccess: -1
D/OpenGLRenderer: endAllActiveAnimators on 0x7219a63c00 (RippleDrawable) with handle 0x721ad62fe0
W/System.err: java.io.IOException: Could not open resulting stream.
W/System.err:     at com.google.firebase.storage.StreamDownloadTask.zzadq(Unknown Source)
W/System.err:     at com.google.firebase.storage.StreamDownloadTask.zza(Unknown Source)
W/System.err:     at com.google.firebase.storage.StreamDownloadTask$1.zzads(Unknown Source)
W/System.err:     at com.google.firebase.storage.StreamDownloadTask$1.call(Unknown Source)
W/System.err:     at com.google.firebase.storage.StreamDownloadTask$zza.zzadu(Unknown Source)
W/System.err:     at com.google.firebase.storage.StreamDownloadTask$zza.read(Unknown Source)
W/System.err:     at java.io.BufferedInputStream.read1(BufferedInputStream.java:273)
W/System.err:     at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
W/System.err:     at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:287)
W/System.err:     at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:350)
W/System.err:     at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:179)
W/System.err:     at java.io.InputStreamReader.read(InputStreamReader.java:184)
W/System.err:     at java.io.Reader.read(Reader.java:140)
W/System.err:     at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2001)
W/System.err:     at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1980)
W/System.err:     at org.apache.commons.io.IOUtils.copy(IOUtils.java:1957)
W/System.err:     at org.apache.commons.io.IOUtils.copy(IOUtils.java:1907)
W/System.err:     at org.apache.commons.io.IOUtils.toString(IOUtils.java:778)
W/System.err:     at org.apache.commons.io.IOUtils.toString(IOUtils.java:759)
W/System.err:     at eu.long1.jwnotes.services.ReceiveService.lambda$handleDownload$2$ReceiveService(ReceiveService.java:186)
W/System.err:     at eu.long1.jwnotes.services.ReceiveService$$Lambda$2.onResult(Unknown Source)
W/System.err:     at eu.long1.jwnotes.helpers.firebase.StorageListener$1.doInBackground(StorageListener.java:48)
W/System.err:     at eu.long1.jwnotes.helpers.firebase.StorageListener$1.doInBackground(StorageListener.java:45)
W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:305)
W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
W/System.err:     at java.lang.Thread.run(Thread.java:761)

就在坠机事故发生之前,我得到了以下信息:

Just before the crash I get this info:

I/DynamiteModule: Considering local module com.google.android.gms.firebasestorage:0 and remote module com.google.android.gms.firebasestorage:6
I/DynamiteModule: Selected remote version of com.google.android.gms.firebasestorage, version >= 6

当然是这样:

private void handleDownload(final String key, ArrayList<String> locations, ArrayList<Talk> talks) {
        for (String location : locations) {
            DatabaseH.getShareTalksReference().child(key).child(location).setValue(null);
        }


        int[] downloadCount = {talks.size()};
        log.d(downloadCount);

        for (final Talk talk : talks) {
            new StorageListener(StorageH.getStream(talk.getPath()), (task) -> {
                try {
                    File file = new File(sTalksFolder, talk.getFileName());
                    talk.setPath(file.getAbsolutePath());

                    InputStream inputStream = task.getResult().getStream();
                    String fileContent = IOUtils.toString(inputStream);
                    TalkFile talkFile = new TalkFile(fileContent);
                    talkFile.setTalk(talk);

                    IOUtils.copy(IOUtils.toInputStream(talkFile.toString()), new FileOutputStream(file));

                    downloadCount[0]--;

                    if (downloadCount[0] == 0) {
                        ReceivedDB.getInstance(context).deleteReceived(locations);
                        SendMessagingService.received(getApplicationContext(), locations);
                        FileSyncService.addFiles(getBaseContext(), talks);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            });
        }
    }

这是getStream()方法:

This is the getStream() method:

public static StreamDownloadTask getStream(String url) {
        return FirebaseStorage.getInstance().getReferenceFromUrl(url).getStream();
}

推荐答案

我知道这已经有一段时间了,但是如果有人知道了,我为解决此问题所做的只是修改访问该项目的规则

I know this has been out for a while, but if anyone gets this, what I did to resolve this issue is just modifying the rule for accessing the item

service firebase.storage {
  match /b/{bucket}/o {
    match /{allPaths=**} {
      allow read, write;
    }
  }
}

我认为默认情况下它希望对用户进行身份验证,但是出于开发目的,我删除了if语句.您可以在存储"部分下的规则"标签中找到此图片

I think by default it wants the user to be authenticated, but for dev purposes I removed that if statement. You'll find this in the rules tab under the storage section

这篇关于Firebase存储10.2.6-&gt;无法打开结果流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆