我正在尝试将多个自定义元数据设置为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"]
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句