【发布时间】:2020-07-23 13:35:23
【问题描述】:
我一直在 Unity 中编写 AR 应用程序,自从我开始使用 Firebase 以来,我刚刚过渡到 ARCore,两者都是 Google 产品。我正在尝试将图像存储在 Firebase 上并在运行时将它们拉到 AugmentedImageDatabase,但由于某种原因,当我尝试下载图像时,Firebase 总是给我一个 FileNotFound 异常。
我通过
引用存储服务和存储桶storageService = Firebase.Storage.FirebaseStorage.DefaultInstance;
storageRef = storageService.GetReferenceFromUrl("gs://avira-cc267.appspot.com"); //Name changed since permissions are temporarily open to public
我尝试通过以下方式下载它们
foreach (Transform obj in imageTargets)
{
Firebase.Storage.StorageReference imageRef = storageRef.Child("ImageTargets/" + obj.gameObject.name + ".jpg");
const long maxAllowedSize = 1024 * 1024; //1mb
imageRef.GetBytesAsync(maxAllowedSize).ContinueWith((Task<byte[]> task) =>
{
if (task.IsFaulted || task.IsCanceled)
{
Debug.Log(task.Exception.ToString()); //This is where the error is called.
}
else
{
byte[] fileContents = task.Result;
callbacks.Enqueue(() => {
Texture2D tex = new Texture2D(2, 2); //size doesnt matter, it gets changed
tex.LoadImage(fileContents);
config.AugmentedImageDatabase.AddImage(obj.gameObject.name, new AugmentedImageSrc(tex), 1f);
});
}
});
}
这是有问题的错误
System.AggregateException: One or more errors occurred. ---> Firebase.Storage.StorageException: Not Found. Could not get object Http Code: 404
我检查了我引用的所有路径,它们都没有错字并且命名正确。 Firebase 中的规则设置为公开
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write;
}
}
}
所以这些不应该给我带来问题。出于某种原因,即使路径与在 Firebase 中显示的路径相同,应用程序也无法找到我引用的图像实例。有谁知道为什么我不能下载我的图像?我在某处引用了错误的路径吗?
编辑:添加图片来证明我的错误
【问题讨论】:
标签: c# firebase unity3d firebase-storage