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

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (6)

我发现了一些其他帖子,但没有解决方案,我发布了这个..

使用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)

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

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 ());
        }
提问于
用户回答回答于

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

扫码关注云+社区

领取腾讯云代金券