storage = Firebase.Storage.FirebaseStorage.DefaultInstance;
storage_ref = storage.GetReferenceFromUrl("--");
StorageReference dw = storage_ref.Child("Folder/"+PlayerPrefs.GetString("key")+".json");
string local_url = Application.dataPath+"/Save Folder/"+storage_ref.Name;
// Start downloading a file
Task task = storage_ref.GetFileAsync(default_path+storage_ref.Name,
new Firebase.Storage.StorageProgress <DownloadState>((DownloadState state) => {
// called periodically during the download
Debug.Log(string.Format(
"Progress: {0} of {1} bytes transferred.",
state.BytesTransferred,
state.TotalByteCount
));
}), CancellationToken.None);
task.ContinueWith(resultTask => {
if (!resultTask.IsFaulted && !resultTask.IsCanceled) {
Debug.Log("Download finished.");
}
});
我尝试从Firebase存储下载文件。
但是未创建local_url
文件。
我还尝试了local_url
中的静态字符串路径,因此解决了这个问题。
答案 0 :(得分:0)
如文档页面所述,不能保证Application.dataPath是可写的(特别是在iOS上它是只读的,在Android上它是APK或OBB [无法写入的不透明档案])
尝试切换到Application.persistentDataPath:
string local_url = $"{Application.persistentDataPath}/Save Folder/{storage_ref.Name}";