Firebase Storage works on desktop but -13010 error on device {Unity}

108 views
Skip to first unread message

Naren Keshav

unread,
Dec 20, 2019, 10:43:26 AM12/20/19
to Firebase Google Group

Development Platform: Mac OS 10.14.6

Unity Version : 2018.4.10f1

Target Mobile OS : iOS 13.0

Firebase Version : 6.8.0

 

Scenario

 

There is a file in the local disk which I want to upload it to a server. The file (_filePath) is checked for it's existence. If present the coroutine uploadADummyFIle() is called. Nothing else matters but a simple upload method.

 

Issue

It works perfectly on my desktop but when I build it on my iOS device - the task "_resultTask" is always faulted. The error code is -13010. The error is

https://firebase.google.com/docs/reference/unity/class/firebase/storage/storage-exception#errorobjectnotfound

 

Code 


private IEnumerator uploadADummyFIle()
{ // This coroutine is only call when _filePath as a file exists
StorageReference _fileReference = Session.StorageContentNodeFor(_fileName);

Task _uploadTask = _fileReference.PutFileAsync(_filePath, null,
     new Firebase.Storage.StorageProgress<UploadState>(_state =>
     {
         float _percentage = (_state.BytesTransferred / _state.TotalByteCount);
         Debug.Log("Progress => " + _percentage);
         
     }), CancellationToken.None, null);

_uploadTask.ContinueWith
   (_resultTask =>
   {

       if (_resultTask.IsFaulted == true)
       {
           int _error = getExceptionFor(_resultTask);
           UnityEngine.Debug.Log("Upload FAULTED");
           UnityEngine.Debug.Log(_error);// Always -13010
   
       }

       if (_resultTask.IsCanceled == true)
       {
           int _error = getExceptionFor(_resultTask);
           UnityEngine.Debug.Log("Upload CANCELLED");
           UnityEngine.Debug.Log(_error);

       }
       Debug.Log("Upload Completed -> " + _resultTask.IsCompleted);
   });
 }

int getExceptionFor(Task _errorTask)
{
      if (_errorTask.Exception is System.AggregateException _aggregateException)
      {
          if (_aggregateException.InnerExceptions[0] is StorageException _innerException)
          {
              return _innerException.ErrorCode;
          }
      }

      return -1;
}

Request
I am quite not sure why it works on my desktop machine but not on my iOS device. If you need any more information beyond what is listed above, please let me know. 
I would like to know why such a problem, how to move forward & if possible the solution itself. 

Thank you, 
Naren

Naren Keshav

unread,
Dec 23, 2019, 11:41:24 AM12/23/19
to Firebase Google Group

I missed a crucial part. In desktop environment, you don't need to append a File path with "file://" but you need to do for iOS device. 

so it is just 
            string _filePath = filePath;

#if UNITY_IOS && (!UNITY_EDITOR)
            _filePath = string.Concat("file://", filePath);
#endif
Reply all
Reply to author
Forward
0 new messages