Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

iOS: access files in asset library



  • I'm currently porting my app to iOS.

    One functionality is that the user can select images via QML FileDialog from the device photo gallery and add them to the app. On Android this is working fine with QFile, QFileInfo or QImage and the provided content-URL, if the necessary rights are granted.

    In iOS FileDialog provides a asset-library URL like this one:
    assets-library://asset/asset.JPG?id=D3232E42-FAEF-4510-B097-79950E0BE5DB&ext=JPG

    Using this with QFileInfo, exists() is true for some files and false for the others. If it's true, then QFileInfo doesn't contain any usable information. For example file size is 0, creation time is invalid and mime type is application/x-zerosize.

    In info.plist the following rights are requested:
    <key>NSCameraUsageDescription</key>
    <string>The app wants to access the camera..</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>The app wants to access the photo gallery.</string>

    I'm using Qt 5.15.1 and testing with iOS 14.2 (emulator).

    Any ideas what I'm missing? Or isn't it possible to access these files via QFile?


Log in to reply