Skip to content

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

Open
@bryanlands

Description

@bryanlands

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:

(ArthurHub/Android-Image-Cropper#466)

Steps to reproduce:

  • Open the MainScene.unity in the quickstart-unity storage sample and replace the UIHandler script with the one attached below

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

UIHandler.cs.zip

  • Update the "MyStorageBucket" path with your cloud storage path
  • Replace the "var localFilenameUriString" in the "protected IEnumerator UploadFromFile()" method with the filepath to an image on your android device.
  • Build the project on Android and click the "Upload from File" button to see the error logged on screen.

(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%

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions