【问题标题】:how to get the download url of an image on firebase in swift?如何快速获取firebase上图像的下载网址?
【发布时间】:2018-09-12 07:29:10
【问题描述】:

新使用 swift 使用 firebase。 我正在尝试获取已上传到 Firebase 存储的图像的下载 url。我尝试了以下代码:

    storageRef.downloadURLWithCompletion { (URL, error) -> Void in
  if (error != nil) {
    // Handle any errors
  } else {
    // Get the download URL for 'images/stars.jpg'
  }
}

我想获取 url 作为字符串。什么是好的做法? 提前致谢。

【问题讨论】:

  • URL 就在您的完成处理程序中。有什么问题/问题?
  • 我想要它作为一个字符串。

标签: ios swift firebase firebase-storage


【解决方案1】:

如果你想获取Url String而不是Url,那么你可以使用Url的absoluteString来获取String Value。

storageRef.downloadURLWithCompletion { (URL, error) -> Void in
  if (error != nil) {
    // Handle any errors
  } else {
    // Get the download URL for 'images/stars.jpg'

    let UrlString = URL.absoluteString

   // you will get the String of Url
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-17
    • 2021-05-27
    • 2019-11-04
    • 2016-11-17
    • 2020-02-03
    相关资源
    最近更新 更多