iosswiftqlpreviewcontroller

Does `QLPreviewItem` works with local files only?


I'm uploading images to firebase and in return I'm getting uploaded image URL as https://firebasestorage.googleapis.com/v0/b/mobile-ae-4a739.appspot.com/o/images%2Feecae5f7-b578-483a-a2da-b166aaf5716c?alt=media&token=b6743df5-7276-4b83-8e2d-f741f42c956e.

Now, I have to display this image in QLPreviewController. I'm giving the above firebase URL of my uploaded image as QLPreviewItem, but QLPreviewController displaying filename text instead of image, you can see in the below screenshot. I confirm that the URL has image.

enter image description here

Can you please help me to show the images in QLPreviewController


Solution

  • QLPreviewItem works with local file URLs only, it won't download your file for you if you provide it a remote file url.

    You need to download your file to your app's local file system before presenting QLPreviewController and provide it that local file url.

    For advanced usage - multiple urls, dataSource, delegate handling - you should watch Quick Look Previews from the Ground Up from WWDC 2018.