firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
825 stars 428 forks source link

Request - Firebase Storage SDK: Natively add mobile prefixes when uploading file via Android/iOS build #684

Open bryanlands opened 4 years ago

bryanlands commented 4 years ago

Please fill in the following fields:

Unity editor version: 2019.3.2f1 Personal Firebase Unity SDK version: 6.11.0 Source you installed the SDK (.unitypackage or Unity Package Manager): .unitypackage Firebase plugins in use (Auth, Database, etc.): Auth, Database, Messaging, Storage Additional SDKs you are using (Facebook, AdMob, etc.): Platform you are using the Unity editor on (Mac, Windows, or Linux): Mac Platform you are targeting (iOS, Android, and/or desktop): Android, iOS Scripting Runtime (Mono, and/or IL2CPP): Mono

Please describe the issue here:

(Please list the full steps to reproduce the issue. Include device logs, Unity logs, and stack traces if available.)

"Firebase.Storage.StorageException: No content provider:" error was raised when image file path from Android device local storage entered directly into storageReference.PutFileAsync().

I resolved this issue by adding "file://" in front of the image path as suggested in the comments from a different issue I found below:

(https://github.com/ArthurHub/Android-Image-Cropper/issues/466)

Steps to reproduce:

https://github.com/firebase/quickstart-unity/tree/master/storage/testapp/Assets/Firebase/Sample/Storage

UIHandler.cs.zip

(If you are getting "no permission" type errors in the log, check that the app has asked for storage permissions, set write permissions to "External SD Card" in the configuration section in Player Settings and use a run time permission plugin such as the one below to ask for permission to access storage)

https://github.com/yasirkula/UnityAndroidRuntimePermissions

I resolved the error by adding "file://" in front of the image path as mentioned earlier. But it may be helpful for the Storage plugin to natively add any required prefixes to the file path depending on build platform (iOS, Android), or update the documentation on the cloud storage guide so that developers new to cloud storage will know the syntax quirks when uploading files on iOS and Android.

Please answer the following, if applicable:

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)?

The issue was found in the quickstarts project

What's the issue repro rate? (eg 100%, 1/5 etc)

100%

chkuang-g commented 4 years ago

@bryanlands

Thank you for reporting this.

Since there are two types of urls: content:// and file://, I think it is required for the developer to specify that in the urls.

At the very least, we can do a bit better job at the documentation here

I'll report this to the team.