ios - 对象 ***********/******.jpg 不存在,Firebase 存储
<p><p>我的问题是当我运行应用程序时,这个错误出现在控制台中</p>
<p>可选(“用户资料/Kk1kKMF89BH778vgd788ju7.jpg 不存在。”)</p>
<p>但该文件存在于我的 Firebase 存储中。我尝试将图像下载到名为 <code>phSelfie</code> 的 UIImage。</p>
<p>这是我的代码:</p>
<pre><code>import UIKit
import Firebase
class SeeSelfieViewController: UIViewController {
var storage = FIRStorage.storage()
@IBOutlet var phSelfie: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
let gsRef = storage.reference(forURL: "gs://******-****.appspot.com/profileUsers/")
let user = FIRAuth.auth()!.currentUser!
let imageRef = gsRef.child("\(user.uid).jpg")
imageRef.data(withMaxSize: 1 * 1024 * 1024) { (data, error) in
if error != nil {
print("\(error?.localizedDescription)") <------ This run the error!!
} else {
let imageSelfie = UIImage(data: data!)
self.phSelfie.image = imageSelfie
print("Succes")
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我发现了一些问题:</p>
<ul>
<li><code>storage.reference(forURL: "gs://******-****.appspot.com/profileUsers/")</code> 应该是一个 HTTP URL,或者你应该只需使用 <code>storage.reference().child("profileUsers")</code></li>
<li><code>Users Profile/Kk1kKMF89BH778vgd788ju7.jpg</code> 对象中似乎有空格,在实际对象名称中会以百分比转义 <code>%20</code>。</li>
<li><code>Users Profile</code> 似乎与上面的对象名称所说的 <code>profileUsers</code> 不匹配...</li>
</ul></p>
<p style="font-size: 20px;">关于ios - 对象 ***********/******.jpg 不存在,Firebase 存储,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/41786443/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/41786443/
</a>
</p>
页:
[1]