我正在尝试将多个自定义元数据设置为 Swift 上的 Firebase 存储
我的代码如下:
let metadata = StorageMetadata()
metadata.contentType = "image/jpg"
metadata.customMetadata = ["lightVibrantColor" : "0"]
metadata.customMetadata = ["imageWidth" : "\(updatedProfileImage.size.width)"]
metadata.customMetadata = ["imageHeight" : "\(updatedProfileImage.size.height)"]
metadata.customMetadata = ["darkMutedColor" : "0"]
但是,只会发送最后的自定义元数据。我知道这一点,因为当我为另一个更改最后一个自定义元数据时,发送的就是那个。
如何添加多个自定义元数据以便将其发送到 Firestore?
最佳答案
您似乎覆盖了该值。您需要将代码更改为:
let metadata = StorageMetadata()
metadata.contentType = "image/jpg"
metadata.customMetadata = ["lightVibrantColor" : "0",
"imageWidth" : "\(updatedProfileImage.size)",
"imageHeight" : "\(updatedProfileImage.size.height)",
"darkMutedColor" : "0"]
关于ios - 添加几个自定义元数据 Firebase Storage swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56590860/