https://kotlinlang.org logo
#android
Title
# android
o

Ofir Bar

02/24/2020, 1:22 PM
Any idea why I can’t return a String to my
uploadFileToFirebase
function? What am I doing wrong? (part in red says):
Copy code
return is not allowed here
r

ribesg

02/24/2020, 1:26 PM
You’re trying to return synchronously in an asynchronous code.
o

Ofir Bar

02/24/2020, 1:33 PM
@ribesg Can you please help? I am really short on time I need to upload a file to Firebase (uses Firebase callbacks), get that file download URL(uses Firebase callbacks), and sent it to my backend (uses coroutines) How can I combine the code above which uses Firebase callbacks with my backend coroutines call? (approximately, pseudocode is good too) This is my method that sends the file download URL to my backend:
r

ribesg

02/24/2020, 1:34 PM
Your function simply cannot return a String because it’s using callbacks, you could add a callback parameter of type
(String) -> Unit
to that function and call it instead of trying to return
(I actually would use
(Result<String>) -> Unit
and call it in the failure listener too)
You’re probably missing a failure listener on
downloadUrl
too
o

Ofir Bar

02/24/2020, 1:36 PM
image.png
true, i have added a failure listener thanks
6 Views