gpt4 book ai didi

ios - 将图像上传到 firebase 存储失败

转载 作者:行者123 更新时间:2023-11-28 07:34:22 24 4
gpt4 key购买 nike

我正在尝试将图像上传到 firebase 存储,但由于某种原因,它失败了。当我尝试上传时,控制台打印出一个重复的错误,如下所示:

2018-12-05 20:00:25.691278-0700 AppName[47183:10835564] [BoringSSL] boringssl_session_errorlog(236) [C4.1:2][0x159ef2a60] [boringssl_session_write] SSL_ERROR_SYSCALL(5): operation failed externally to the library 2018-12-05 20:00:25.693021-0700 AppName[47183:10835564] [BoringSSL] boringssl_session_errorlog(236) [C4.1:2][0x159ef2a60] [boringssl_session_write] SSL_ERROR_SYSCALL(5): operation failed externally to the library 2018-12-05 20:00:25.697283-0700 AppName[47183:10835564] [BoringSSL] boringssl_session_errorlog(236) [C4.1:2][0x159ef2a60] [boringssl_session_write] SSL_ERROR_SYSCALL(5): operation failed externally to the library

我的代码如下:

func uploadImage(_ image: UIImage){
let storage = Storage.storage()
let storageRef = storage.reference()
let imageRef = storageRef.child("images")

if let data: Data = image.pngData() {
imageRef.putData(data, metadata: nil)
}

}

我不确定发生了什么或错误到底是什么。感谢您的帮助。

最佳答案

尝试:

func uploadPhoto(picture:UIImage?) {
if let img = picture, let data = UIImageJPEGRepresentation(img, 1){
let path = "\(NSDate.timeIntervalSinceReferenceDate)" // name of image
let metaData = StorageMetadata()
metaData.contentType = "image/jpg"
let ref = Storage.storage().reference().child("images").child(path)
ref.putData(data, metadata: metaData) { (mData, error) in
if error == nil{
ref.downloadURL(completion: { (url, error) in
if error == nil{
print(url?.absoluteString)
}
})
}
}
}
}

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

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