gpt4 book ai didi

ios - 用于图像上传的 Firebase 存储

转载 作者:行者123 更新时间:2023-11-29 05:34:18 25 4
gpt4 key购买 nike

用于图像上传的 Firebase 存储问题:“存储桶无法使用路径初始化”

当我们尝试拉取 putData 方法时发生

我们尝试了以下方法:

storage.storage().reference().child("Images").child("image1.jpg")
reference().document(object.id).setData(data,merge:true)

storage.storage().reference().child("Images").child("image1.jpg")
reference().document(object.id).setData(data,merge:true)

最佳答案

我知道您在存储图像时遇到问题,请尝试这种方式

    let imageName = "image1.jpg"
let image = UIImage(named: imageName)
let store = Storage.storage()
let metadata = StorageMetadata()
metadata.contentType = "image/jpeg"
let imageData: Data = UIImageJPEGRepresentation(image, 0.5)!
let storeRef = store.reference().child("Images")
let _ = storeRef.putData(imageData, metadata: metadata) { (metadata, error) in
guard let _ = metadata else {
print("error occurred: \(error.debugDescription)")
return
}
let pat = (metadata?.downloadURL()?.absoluteString.description)
let link = pat! //Link of image

}

关于ios - 用于图像上传的 Firebase 存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57209877/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com