- Home /
URL Escaping for Firebase
I am trying to download a image stored in the Firebase Storage, using Unity. I use Unity Firebase SKD (in Beta...). This is my code:
...
// Points to "1/preview.jpg"
Firebase.Storage.StorageReference img_ref = folder1_ref.Child("/preview.jpg");
// Fetch the download URL
img_ref.GetDownloadUrlAsync().ContinueWith(task => {
Debug.Log(task.Result.ToString());
});
The console output is:
https://firebasestorage.googleapis.com/v0/b/insidehome-29c9e.appspot.com/o/1/preview.jpg?alt=media&token=092a8de8-5047-4bce-b179-edd4101847a3
If I try to download the file using www or a browser, with this URL, I obtain an error. The good URL should be (copied by Firebase console):
https://firebasestorage.googleapis.com/v0/b/insidehome-29c9e.appspot.com/o/1%2fpreview.jpg?alt=media&token=092a8de8-5047-4bce-b179-edd4101847a3
The difference is only in a single slash ("/") before the word "preview", transformed in %2f
Is this strange? How could I fix it? I try Escape the URL but it change all the slash:
https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Finsidehome-29c9e.appspot.com%2Fo%2F1%2F99%2Fobama.jpg%3Falt%3Dmedia%26token%3D8a33f998-e271-4d7e-8848-356a332b7750
And It does't work. I need to change only the parameters (right) slash
Answer by anjuman · Jun 19, 2017 at 05:20 AM
task.Result.OriginalString will work.
reference.GetDownloadUrlAsync ().ContinueWith ((task) =>
{
if (task.IsFaulted || task.IsCanceled) {
Debug.Log(task.Exception.ToString());
// Uh-oh, an error occurred!
} else {
uri = task.Result.OriginalString;
}
});
Your answer
Follow this Question
Related Questions
Cannot load image from URL passed as parameter 0 Answers
What is the correct way to store 1000's of images in a Unity project? 1 Answer
Integrated VideoPlayer component but for images? 0 Answers
How to prevent unescaping redirected url?,how to prevent unescaping redirected url? 0 Answers
How to get a random image url from google image search 0 Answers