J. Doe
J. Doe

Reputation: 285

absolute string -> "Value of type 'StorageMetadata' has no member 'downloadURL'"

Just update new firebase, now I get the above error in the 10th line... It worked under firebase 3 and 4, but as they deleted the downloadURL its not working in the fifth version anymore... please don't duplicate this question or similar as I already tried any solution on the internet and nothing worked...

fileprivate func handleVideoSelectedForUrl(_ url: URL) {
    let filename = UUID().uuidString + ".mov"
    let uploadTask = Storage.storage().reference().child("message_movies").child(filename).putFile(from: url, metadata: nil, completion: { (metadata, error) in

        if error != nil {
            print("Failed upload of video:", error!)
            return
        }

        if let videoUrl = metadata?.downloadURL()?.absoluteString {
            if let thumbnailImage = self.thumbnailImageForFileUrl(url) {
                self.uploadToFirebaseStorageUsingImage(thumbnailImage, completion: { (imageUrl) in
                    let properties: [String: AnyObject] = ["imageUrl": imageUrl as AnyObject, "imageWidth": thumbnailImage.size.width as AnyObject, "imageHeight": thumbnailImage.size.height as AnyObject, "videoUrl": videoUrl as AnyObject]
                    self.sendMessageWithProperties(properties)

                })
            }
        }
    })

Upvotes: 1

Views: 240

Answers (1)

Arjun Patel
Arjun Patel

Reputation: 1510

// In putData response closer You can get downloadURL with below updated code

metadata?.storageReference?.downloadURL(completion: { (url, error) in
              print(url)
            })

Before this You can retire like

metadata?.downloadURL()

Upvotes: 1

Related Questions