firebase-ios-sdk: Cannot upload file to Storage. uploadTask.putFile callback is not called

[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)")
                }
            }
        }

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 21 (8 by maintainers)

Most upvoted comments

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