如何将图像上传到Firebase

问题描述 投票:-2回答:1

我如何重组我的代码以从"atappspot.com/").child("profileImage.jpg").child(user.uid)"开始,它转换为appspot.com/profileimage.jpg/Y789i90k0d0ifunb的路径,最后一部分是uid。到appspot.com/Y789i90k0d0ifunb/profileimage.jpg,以便可以在Firebase存储中查看我的图像?

let StorageRef = Storage.storage().reference(forURL: "gs://tunnel-vision-458d6.appspot.com/").child("profileImage.jpg").child(user.uid)
swift firebase firebase-storage
1个回答
0
投票

Cloud Storage中映像的路径是按照在代码中的顺序生成的。您可以这样构建它:

let StorageRef = Storage.storage()
    .reference(forURL: "gs://tunnel-vision-458d6.appspot.com/")
    .child("profileImage.jpg")
    .child(user.uid)

以上转换为路径profileImage.jpg/$uid。如果要在文件名之前使用UID,请交换两个child调用:

let StorageRef = Storage.storage()
    .reference(forURL: "gs://tunnel-vision-458d6.appspot.com/")
    .child(user.uid)
    .child("profileImage.jpg")
© www.soinside.com 2019 - 2024. All rights reserved.