Google Firebase iOS build 在 Mac 上将文件上传到存储,但在 iPad 上 运行 时触发 StorageException
Google Firebase iOS build uploads file to storage on Mac, but triggers StorageException when running on iPad
我使用 Unity (2019.4) 和 Google Firebase SDK 构建了一个 iOS 应用程序。在此场景中,我从 BLE 设备获取数据,将其写入 .csv,然后将此 .csv 上传到 Firebase 存储。当我在 Mac (OS 10.15.7) 上的 Unity 编辑器中 运行 这个应用程序时,.csv 文件会正确上传。但是,当我将此脚本构建到我的 iPad Pro (14.4.2) 时,我得到一个 StorageException:
Autoconnected Player Failed to upload because System.AggregateException: One or more errors occurred. ---> Firebase.Storage.StorageException: No object exists at the desired reference
管理我的 .csv 上传的协程在这里:
private IEnumerator UploadCSV()
{
string filepath = GetComponent<CSVManager>().WriteCSV();
fbS = FirebaseStorage.DefaultInstance;
var CSVReference = fbS.GetReferenceFromUrl($"gs://ice-app-12.appspot.com/sessioncsv/{Guid.NewGuid()}.csv");
var uploadTask = CSVReference.PutFileAsync(filepath);
yield return new WaitUntil(() => uploadTask.IsCompleted);
if (uploadTask.Exception != null)
{
Debug.LogError($"Failed to upload because {uploadTask.Exception}");
yield break;
}
var getUrlTask = CSVReference.GetDownloadUrlAsync();
yield return new WaitUntil(() => getUrlTask.IsCompleted);
if (getUrlTask.Exception != null)
{
Debug.LogError($"Failed to get a download url with {getUrlTask.Exception}");
yield break;
}
Debug.Log($"Download from {getUrlTask.Result}");
}
几天来我一直在为这个问题苦苦挣扎。我很困惑,因为问题似乎出在 CSVReference 中,但我不明白为什么脚本可以在我的 Mac 上正常运行,但不能在我的 iPad 上正常运行。如果有任何帮助,我将不胜感激!
对于它的价值,我能够通过从 PutFileAsync() 上传函数切换到 PutBytesAsync() 来解决错误。为此,我必须将本地数据结构从 .csv 文件更改为字节数组。进行此切换后,我就可以将 .csv 文件上传到我的 firebase 存储桶。
我仍然不明白为什么我只在 iPad 上收到 PutFileAsync() 错误。但此解决方案目前有效。
我使用 Unity (2019.4) 和 Google Firebase SDK 构建了一个 iOS 应用程序。在此场景中,我从 BLE 设备获取数据,将其写入 .csv,然后将此 .csv 上传到 Firebase 存储。当我在 Mac (OS 10.15.7) 上的 Unity 编辑器中 运行 这个应用程序时,.csv 文件会正确上传。但是,当我将此脚本构建到我的 iPad Pro (14.4.2) 时,我得到一个 StorageException:
Autoconnected Player Failed to upload because System.AggregateException: One or more errors occurred. ---> Firebase.Storage.StorageException: No object exists at the desired reference
管理我的 .csv 上传的协程在这里:
private IEnumerator UploadCSV()
{
string filepath = GetComponent<CSVManager>().WriteCSV();
fbS = FirebaseStorage.DefaultInstance;
var CSVReference = fbS.GetReferenceFromUrl($"gs://ice-app-12.appspot.com/sessioncsv/{Guid.NewGuid()}.csv");
var uploadTask = CSVReference.PutFileAsync(filepath);
yield return new WaitUntil(() => uploadTask.IsCompleted);
if (uploadTask.Exception != null)
{
Debug.LogError($"Failed to upload because {uploadTask.Exception}");
yield break;
}
var getUrlTask = CSVReference.GetDownloadUrlAsync();
yield return new WaitUntil(() => getUrlTask.IsCompleted);
if (getUrlTask.Exception != null)
{
Debug.LogError($"Failed to get a download url with {getUrlTask.Exception}");
yield break;
}
Debug.Log($"Download from {getUrlTask.Result}");
}
几天来我一直在为这个问题苦苦挣扎。我很困惑,因为问题似乎出在 CSVReference 中,但我不明白为什么脚本可以在我的 Mac 上正常运行,但不能在我的 iPad 上正常运行。如果有任何帮助,我将不胜感激!
对于它的价值,我能够通过从 PutFileAsync() 上传函数切换到 PutBytesAsync() 来解决错误。为此,我必须将本地数据结构从 .csv 文件更改为字节数组。进行此切换后,我就可以将 .csv 文件上传到我的 firebase 存储桶。
我仍然不明白为什么我只在 iPad 上收到 PutFileAsync() 错误。但此解决方案目前有效。