【问题标题】:How to get the image path stored in the iCloud?如何获取存储在 iCloud 中的图像路径?
【发布时间】:2017-11-04 15:00:09
【问题描述】:

我使用TLPhotoPicker 允许用户选择多个图像。我想将图片上传到 Firebase,并根据他们的documentation,我需要检索图片的路径。

@Eridana 回答here,如下:

PHImageManager.default().requestImageData(for: selectedAssets[0].phAsset!, options: PHImageRequestOptions(), resultHandler:
            {
                (imagedata, dataUTI, orientation, info) in
                if info!.keys.contains(NSString(string: "PHImageFileURLKey"))
                {
                    let path = info![NSString(string: "PHImageFileURLKey")] as! NSURL
                    print(path)
                } else {

                }
        })

在设备中工作并打印本地图像的路径 (file:///var/mobile/Media/DCIM/100APPLE/IMG_0005.PNG),但是当我选择存储在 iCloud 中的图像时,控制台打印出以下错误:

2017-11-04 18:17:44.423826+0400 tourPlacesApp[242:8831] [通用] 未能加载资产的图像数据 C2717B20-5180-4CE8-AFEB-D661C259D227/L0/001 mediaType=1/0, sourceType=1, (2448x3264), creationDate=2017-07-02 06:46:00 +0000, location=1, hidden=0, favorite=0 格式为 9999

我在网上看了一下,发现我必须先把图片的元数据保存在本地文件中,然后才能得到图片的路径。

如何从存储为 PHAsset 的图像中获取元数据

编辑

它在Apple docs 中说如果图像在 iCloud 中,我需要下载该图像,但我找不到他们解释如何下载图像的位置。

【问题讨论】:

标签: ios swift firebase-storage phasset


【解决方案1】:

解决方案是,在您的TLPhotosPickerViewController.swift 类中首先搜索cloud,然后取消注释与cloud 相关的所有方法和变量,特别是requestCloudDownload(asset: asset, indexPath: indexPath) 方法

【讨论】:

  • 尝试解释为什么我们必须这样做
  • tlphotopicker 不允许从 icloud 下载图像,因为 icloud 上的内容被认为是该用户的私有内容, requestCloudDownload(asset: assets, indexPath: indexPath) 方法允许我们进入用户的 icloud 和下载图片...谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-01-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-08
  • 1970-01-01
相关资源
最近更新 更多