Skip to content

Cannot upload file to Storage. uploadTask.putFile callback is not called #1888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kainjinez opened this issue Sep 28, 2018 · 21 comments · Fixed by #1981
Closed

Cannot upload file to Storage. uploadTask.putFile callback is not called #1888

kainjinez opened this issue Sep 28, 2018 · 21 comments · Fixed by #1981
Milestone

Comments

@kainjinez
Copy link

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 10
  • Firebase SDK version: Newest from Git
  • Firebase Component: Storage (Auth, Core, Database, Firestore, Messaging, Storage, etc)
  • Component version: Newest from branch master

[REQUIRED] Step 3: Describe the problem

I'm developing uploading screenshot to Storage for macOS application. I used these code below, it does not throw any error or crash. I don't see any new file on Storage after upload and callback at putFile won't be called.

Steps to reproduce:

        let storage = Storage.storage()
        let localFile = URL(string: "/Users/truonghieu/Library/Containers/com.example.appname/Data/Documents/appname/image.jpg")
        let storageRef = storage.reference().child("abc.jpg")
        let uploadTask = storageRef.putFile(from: localFile!, metadata: nil) { metadata, error in
            guard metadata != nil else{
                print("error: \(String(describing: error?.localizedDescription))")
                return
            }
            let fileManager = FileManager.default
            if fileManager.fileExists(atPath: localPath) {
                do {
                    try fileManager.removeItem(at: localFile!)
                    print("success: move item\(localPath)")
                }catch{
                    print("failed: move item\(localPath)")
                }
            }
        }

@paulb777
Copy link
Member

@kainjinez We might be able to help you here, but usage questions are more appropriate for stackoverflow.

@kainjinez
Copy link
Author

@paulb777 Hi Paul,
I use these code similar to what i see in Firebase Storage document. So I think this is maybe a bug or i need to do anything more to let it works, because this is a product of community, maybe~

@schmidt-sebastian
Copy link
Contributor

Unfortunately, we don't currently have any debug logging in our Storage SDKs. Are you able to verify that we are able to connect to the backend (by monitoring the app's network traffic through Activity Monitor or similar?). How large is the file you are uploading?

@kainjinez
Copy link
Author

@schmidt-sebastian Hi Sebastian,
For verifying connection, i am able to login/register using Firebase Auth.
My files is just a screenshot with 2MB max.
I tried to downgrade the Firebase SDK from 5.x to 4.8.0 and above code works.

@sohilmemon
Copy link

Please solve this issue! I am also facing the same. I have done all the changes and after 12 hours I came to know that the issue exists in SDK. Success / Error callback doesn't call!

@kainjinez
Copy link
Author

@sohilmemon You may try to downgrade the SDK to this version, it works for me. Use this and wait for their fix
https://drive.google.com/file/d/12jZl9xjP7KVOjIHGioHwctgZMYhvaFo5/view?usp=sharing

@schmidt-sebastian
Copy link
Contributor

@sohilmemon Are you also using the MacOS version of the SDK?

@azeemse
Copy link

azeemse commented Oct 17, 2018

Did anyone find the solution to this issue? I am still facing this issue using iOS SDK version v5.7

@kainjinez
Copy link
Author

Did anyone find the solution to this issue? I am still facing this issue using iOS SDK version v5.7

You can temporary pass through this issue by using older version. Check drive link above.

@schmidt-sebastian
Copy link
Contributor

schmidt-sebastian commented Oct 18, 2018

@kainjinez @azeemse @sohilmemon Does one of you have a minimal code sample that could reproduce this issue? I would like to drill down which release between 4.8 and 5.7 introduced this regression and am having a hard time since the callbacks fire for me.

A good starting point would be the quickstart app: https://github.com/firebase/quickstart-ios/tree/master/storage

Do you see the same issues there?

What device are you encountering this issue on?

@h36ahmed
Copy link

h36ahmed commented Oct 19, 2018

Hi there, I am also finding this issue as well with the latest version of Firebase. I cannot upload file and there is no callback. I have tried both putData and putFile. I get no errors, no progress. If this could be resolved asap, it would be awesome of you guys!

@schmidt-sebastian
Copy link
Contributor

Since I have not heard any reports, I assume that downloads work fine?

@kainjinez
Copy link
Author

@schmidt-sebastian since i faced this problem when developing MacOS app, then I cannot check your quickstart because it belong to iPhone app. Even it works with iPhone, it may not related with this issue.

@h36ahmed
Copy link

h36ahmed commented Oct 20, 2018

So I tested out various scenarios. So far my findings have been that putFile works iOS simulator but not for actual device testing.
Here is the error that I get when I try to upload an image to Storage from actual device using the quickstart app: Domain=FIRStorageErrorDomain Code=-13000 "An unknown error occurred, please check the server response."
However, .putData works for image uploading both actual device and simulator.
However, I am trying to upload audio, .wav, files onto Firebase and both putData and putFile don't work at all.

@h36ahmed
Copy link

h36ahmed commented Oct 20, 2018

Okay so update from me is that I believe I figured what was wrong with my code. I was calling the api on another thread other than main and hence, I used DispatchQueue.main.async { myCode }and it worked like a charm. Hope this helps anyone. Nothing wrong with Firebase Storage code.

@azeemse
Copy link

azeemse commented Oct 21, 2018

Since I have not heard any reports, I assume that downloads work fine?

I was using the latest version of Firebase for the first time in any of my project so I just followed the documentation.
Performed each and every step 1 by 1 and reached to the point where I needed to upload the profile image to Storage.

Copied the code written in documentation and pasted in my project to just check how it works and what it returns but the code never ran successfully. It executed and observes the "progress" status but never returns any "completion block"

And most interestingly no help is available on Stack Overflow or any other platform. This thread gave me some clue that this is the issue of SDK so I tried @kainjinez solutions, turned down the version to 4.8.0 and it simply started working.

Things to remember, I am building an iOS application

Xcode: 10.0
Technology: Swift 4.2
Minimum Deployment Target: iOS v10.0

@azeemse
Copy link

azeemse commented Oct 21, 2018

Okay so update from me is that I believe I figured what was wrong with my code. I was calling the api on another thread other than main and hence, I used DispatchQueue.main.async { myCode }and it worked like a charm. Hope this helps anyone. Nothing wrong with Firebase Storage code.

With the latest iOS SDK, I tried this solution but this didn't work for me. Details are mentioned in my above comment.

@schmidt-sebastian
Copy link
Contributor

Thanks for all your help :) We already looked into moving the Storage internal operations off the main queue, and this thread is now another good reason to do so. We will release a fix soon.

@paulb777 paulb777 added this to the M37 milestone Oct 23, 2018
@azeemse
Copy link

azeemse commented Nov 2, 2018

Thanks for all your help :) We already looked into moving the Storage internal operations off the main queue, and this thread is now another good reason to do so. We will release a fix soon.

Is this issue is resolved and Can I update my pods to the latest version now?

@schmidt-sebastian
Copy link
Contributor

We are still working on the release. The fix will be out in the next couple of days.

@paulb777
Copy link
Member

paulb777 commented Nov 2, 2018

The milestone associated with this issue will be closed when 5.12.0 is published.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants