Skip to content

Commit

Permalink
Merge pull request #435 from syntaxerror247/storage_error_reporting_3.x
Browse files Browse the repository at this point in the history
Fix storage error handling 3.x
  • Loading branch information
WolfgangSenff authored Sep 26, 2024
2 parents b2cb040 + 65f79c2 commit 24ae268
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions addons/godot-firebase/storage/storage.gd
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func _check_emulating() -> void :

func _upload(data : PoolByteArray, headers : PoolStringArray, ref : StorageReference, meta_only : bool) -> StorageTask:
if not (_config and _auth):
Firebase._printerr("Error uploading to storage: Invalid authentication")
return null

var task := StorageTask.new()
Expand All @@ -173,6 +174,7 @@ func _upload(data : PoolByteArray, headers : PoolStringArray, ref : StorageRefer

func _download(ref : StorageReference, meta_only : bool, url_only : bool) -> StorageTask:
if not (_config and _auth):
Firebase._printerr("Error downloading from storage: Invalid authentication")
return null

var info_task := StorageTask.new()
Expand Down Expand Up @@ -207,6 +209,7 @@ func _download(ref : StorageReference, meta_only : bool, url_only : bool) -> Sto

func _list(ref : StorageReference, list_all : bool) -> StorageTask:
if not (_config and _auth):
Firebase._printerr("Error getting object list from storage: Invalid authentication")
return null

var task := StorageTask.new()
Expand All @@ -218,6 +221,7 @@ func _list(ref : StorageReference, list_all : bool) -> StorageTask:

func _delete(ref : StorageReference) -> StorageTask:
if not (_config and _auth):
Firebase._printerr("Error deleting object from storage: Invalid authentication")
return null

var task := StorageTask.new()
Expand Down Expand Up @@ -268,6 +272,8 @@ func _finish_request(result : int) -> void:

StorageTask.Task.TASK_DOWNLOAD_URL:
var json : Dictionary = JSON.parse(_response_data.get_string_from_utf8()).result
if json and json.has("error"):
Firebase._printerr("Error getting download url: "+json["error"].message)
if json and json.has("downloadTokens"):
task.data = _base_url + _get_file_url(task.ref) + "?alt=media&token=" + json.downloadTokens
else:
Expand All @@ -276,6 +282,8 @@ func _finish_request(result : int) -> void:
StorageTask.Task.TASK_LIST, StorageTask.Task.TASK_LIST_ALL:
var json : Dictionary = JSON.parse(_response_data.get_string_from_utf8()).result
var items := []
if json and json.has("error"):
Firebase._printerr("Error getting data from storage: "+json["error"].message)
if json and json.has("items"):
for item in json.items:
var item_name : String = item.name
Expand Down

0 comments on commit 24ae268

Please sign in to comment.