我正在尝试使用firebase存储来上传图片。 这是我尝试过的。
public void firetalk(string path)
{
Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;
Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://<myurl>.appspot.com/");
Firebase.Storage.StorageReference art_image_ref = storage_ref.Child("images/innocence.jpg");
art_image_ref.PutFileAsync(path).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.
Firebase.Storage.StorageMetadata metadata = task.Result;
string download_url = metadata.DownloadUrl.ToString();
Debug.Log("Finished uploading...");
Debug.Log("download url = " + download_url);
}
});
}
firetalk功能接收路径,我使用PutFileAsync
使用路径上传,但是我收到此错误..
System.AggregateException: Exception of type 'System.AggregateException' was thrown.
-----------------
Firebase.Storage.StorageException: Permission denied. Could not perform this operation
UnityEngine.Debug:Log(Object)
GracesGames.SimpleFileBrowser.Scripts.explorer_script:m__0(Task`1) (at Assets/scripts/explorer_script.cs:85)
System.Threading.Tasks.TaskCompletionSource`1:SetException(Exception)
Firebase.Storage.StorageReference:CompleteTask(Task`1, TaskCompletionSource`1, Func`1, String, Boolean)
Firebase.Storage.c__AnonStorey6:<>m__0(Task`1)
System.Threading.Tasks.TaskCompletionSource`1:SetException(Exception)
Firebase.Storage.c__AnonStorey0:<>m__0()
Firebase.Storage.Future_StorageMetadata:SWIG_CompletionDispatcher(Int32)
Firebase.AppUtilPINVOKE:PollCallbacks()
Firebase.AppUtil:PollCallbacks()
Firebase.Platform.FirebaseAppUtils:PollCallbacks()
Firebase.Platform.FirebaseHandler:Update()
Firebase.Platform.FirebaseMonoBehaviour:Update()
任何猜测?