为什么GetDownloadUrlAsync()返回“发生未知错误”

时间:2019-05-09 19:12:19

标签: firebase unity3d firebase-storage

我发现了其他一些帖子,但没有解决方案,我正在发布此帖子。

使用Firebase示例,我可以将文件上传到Firebase存储,但无法获取GetDownloadUrlAsync()-它返回未知错误:

GetDownloadUrlAsync: System.AggregateException: One or more errors 
occurred. ---> Firebase.Storage.StorageException: An unknown error 
occurred
--- End of inner exception stack trace ---
---> (Inner Exception #0) Firebase.Storage.StorageException: An 
unknown error occurred<---

System.Action`1:Invoke(T)
System.Threading.Tasks.Task:Execute()
System.Threading.ContextCallback:Invoke(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, 
ContextCallback, Object, Boolean)
System.Threading.Tasks.Task:ExecuteWithThreadLocal(Task&)
System.Threading.Tasks.Task:ExecuteEntry(Boolean)
System.Threading.ThreadPoolWorkQueue:Dispatch()

(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 48)

这发生在协程中。这是我的代码:

Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;
Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://mystoragelocation.appspot.com");

Firebase.Storage.StorageReference image_ref = storage_ref.Child(file_name);
    var task = image_ref.PutFileAsync(path);

    yield return new WaitUntil(() => task.IsCompleted);
    if (task.IsFaulted) {
        uploadWait.SetActive(false);
        result.text = task.Exception.ToString();
        DebugLog ("Upload Error: " + task.Exception.ToString ());
        throw task.Exception;

    } else {

    storage_ref.GetDownloadUrlAsync().ContinueWith((task2) => {
    if (!task2.IsFaulted && !task2.IsCanceled) {
        DebugLog("Finished uploading... Download Url: " + task2.Result);
    } else {
        DebugLog ("GetDownloadUrlAsync: " + task2.Exception.ToString ());
        }

1 个答案:

答案 0 :(得分:0)

使用了错误的参考!需要使用image_ref !!!