0

I am using TLPhotoPicker to allow the user to choose multiple images. I want to upload the images to Firebase and based on their documentation, I need to retrieve the image's path.

@Eridana answer here, which is as follows:

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 {

                }
        })

Works and prints the local image's path in the device (file:///var/mobile/Media/DCIM/100APPLE/IMG_0005.PNG), but when I choose images stored in the iCloud, I get the following error printed to the console:

2017-11-04 18:17:44.423826+0400 tourPlacesApp[242:8831] [Generic] Failed to load image data for asset 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 with format 9999

When I looked online, I found that I have to store the metadata of the images first inside local file and only then I will be able to get the image path.

How do I get the metadata from the images stored as PHAsset

EDIT

It says in Apple docs that I need to download the image if it is in the iCloud, but I couldn't find where they explain how to download the image.

Community
  • 1
  • 1
Behrouz Riahi
  • 1,751
  • 2
  • 21
  • 42
  • after 0.001 secs of googling, _violá_, that is about [iCloud file management](https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/iCloud/iCloud.html). – holex Jan 23 '18 at 08:57

1 Answers1

0

The solution is, in your TLPhotosPickerViewController.swift class first search for cloud and then uncomment all methods and variables related to cloud, specially requestCloudDownload(asset: asset, indexPath: indexPath) method

Neji Soltani
  • 1,522
  • 4
  • 22
  • 41
  • try to explain why we have to do this – Neji Soltani Jan 23 '18 at 08:40
  • tlphotopicker does not allow to download images from icloud, because content on icloud are considered to be private for that user, requestCloudDownload(asset: asset, indexPath: indexPath) method allows us to enter into user's icloud and download images...thanks – Vijay sharma Feb 05 '18 at 08:42