更新Firebase容器后出现错误。 <downloadurl> <storageref>

时间:2018-07-12 17:09:25

标签: ios swift firebase firebase-storage

升级了我的Firebase吊舱,并出现了很多错误。我在Firebase文档网页上使用了文档,因此能够修复其中的大多数文档。任何帮助深表感谢。谢谢

错误:

  1. “ StorageMetadata”类型的值没有成员“ downloadURL”

  2. “ StorageReference”类型的值没有成员“ put”

完整代码:

var port = process.env.PORT || 3001;

错误1。>如果让videoUrl =元数据?.downloadURL()?. absoluteString {

import Foundation
import FirebaseStorage
class HelperService {
    static func uploadDataToServer(data: Data, videoUrl: URL? = nil, ratio: CGFloat, caption: String, onSuccess: @escaping () -> Void) {
        if let videoUrl = videoUrl {
            self.uploadVideoToFirebaseStorage(videoUrl: videoUrl, onSuccess: { (videoUrl) in
                uploadImageToFirebaseStorage(data: data, onSuccess: { (thumbnailImageUrl) in
                    sendDataToDatabase(photoUrl: thumbnailImageUrl, videoUrl: videoUrl, ratio: ratio, caption: caption, onSuccess: onSuccess)
                })
            })
            //self.senddatatodatabase
        } else {
            uploadImageToFirebaseStorage(data: data) { (photoUrl) in
                self.sendDataToDatabase(photoUrl: photoUrl, ratio: ratio, caption: caption, onSuccess: onSuccess)
            }
        }
    }

    static func uploadVideoToFirebaseStorage(videoUrl: URL, onSuccess: @escaping (_ videoUrl: String) -> Void) {
        let videoIdString = NSUUID().uuidString
        let storageRef = Storage.storage().reference(forURL: Config.STORAGE_ROOF_REF).child("posts").child(videoIdString)
        storageRef.putFile(from: videoUrl, metadata: nil) { (metadata, error) in
            if error != nil {
                ProgressHUD.showError(error!.localizedDescription)
                return
            }

错误2。> storageRef.put(数据,元数据:无){(元数据,错误)

                onSuccess(videoUrl)
            }
        }
    }

    static func uploadImageToFirebaseStorage(data: Data, onSuccess: @escaping (_ imageUrl: String) -> Void) {
        let photoIdString = NSUUID().uuidString
        let storageRef = Storage.storage().reference(forURL: Config.STORAGE_ROOF_REF).child("posts").child(photoIdString)

1 个答案:

答案 0 :(得分:1)

从上传元数据获取下载URL的功能已删除。相反,您可以使用StorageReference.downloadURL()

要上传文件,您可以选择一些选项,如API docs here所示。您可以看到putDataputFile上有变体,但没有put