firebase / quickstart-cpp

Firebase Quickstart Samples for C++
https://firebase.google.com/games
Apache License 2.0
206 stars 122 forks source link

Storage: Unable to create StorageReference from URL #26

Closed tuyenit7 closed 6 years ago

tuyenit7 commented 6 years ago

I had that issue when moving firebase implementation (Analytics, RealtimeDB, RemoteConfig, Storage) from native android sdk to cpp sdk. Everything seem to be OK but when i tried to get reference by calling GetReferenceFromUrl() it return error: -Unable to create StorageReference from URL - URL specifies a different bucket (firebasestorage.googleapis.com) than this instance ([my custom bucket]). My URL is download URL of Firebase storage (https://firebasestorage.googleapis.com/v0/b/[my custom bucket]/o/ [my file]). Note: it work fine when i using native android SDK. Please help!

stewartmiles commented 6 years ago

The Android implementation actually has a bug that allows you to create a storage reference using a different bucket to the bucket used to create the storage object. In the C++ implementation to be consistent across all platform (Android, iOS & desktop) we make sure that you can't do this on Android even though it's feasibly possible and incorrect. To fix this issue you should instead create a firebase::storage::Storage instance for the bucket then get a references for that bucket from the new instance instead.

tuyenit7 commented 6 years ago

Hi, thank you for your explanation. I'd tried follow your suggest successful. Thanks again!