【发布时间】:2019-03-28 04:55:43
【问题描述】:
您好我正在尝试通过 Unity 2018.2.10f1 将本地图像文件上传到 Firebase 存储,我得到的错误是
System.AggregateException:引发了“System.AggregateException”类型的异常。
我正在使用名为"NativeGallery" 的 Unity 插件从 Android 库中检索本地图像文件。
有谁知道是什么导致了这个错误?
这是我的代码:
protected FirebaseStorage storage;
protected StorageReference storage_ref;
private string imagePath;
private void Start(){
storage = Firebase.Storage.FirebaseStorage.DefaultInstance;
// Create a storage reference from our storage service
storage_ref = storage.GetReferenceFromUrl("my Storage URL");
}
//Opens the Android Gallery Prompt/Window
public void PickImageFromGallery(int maxSize = 1024)
{
NativeGallery.GetImageFromGallery((path) =>
{
if (path != null)
{
imagePath = path;
Debug.Log("Selected Image " + path);
}
}, maxSize: maxSize);
}
//Uploads Selected Image File
public void Upload()
{
if(imagePath != null)
{
// Create a reference to the file you want to upload
StorageReference sRef = storage_ref.Child("Work/Photos/image.jpeg");
// Upload the file to the path "images/rivers.jpg"
sRef.PutFileAsync(imagePath)
.ContinueWith((Task<StorageMetadata> task) => {
if (task.IsFaulted || task.IsCanceled)
{
Debug.Log(task.Exception.ToString());
// Uh-oh, an error occurred!
}
else
{
// Metadata contains file metadata such as size, content-type, and download URL.
StorageMetadata metadata = task.Result;
string download_url = sRef.ToString();
Debug.Log("Finished uploading...");
Debug.Log("download url = " + download_url);
}
});
}
}
【问题讨论】:
标签: c# firebase unity3d local-storage firebase-storage