iOS - FileInputStream::openHandle fails with FileChooser result


when using FileChooser and using the native Document browser on iOS to open a file, opening the result with a FileInputStream fails.

The error message from FileInputStream contains the message Operation not permitted.

I have iCloud enabled in Projucer, I’m using a Provisioning Profile that has iCloud permissions, and I have an iCloud container setup and allow iCloud Documents access. Am I missing anything?

This fails on an image file. When I open a .xml through FileChooser however and opening it with XmlDocument::parse() I have no problems and it opens as expected. XmlDocument opens an InputStream on the file internally, so is basically doing the same thing as I’m doing in my FileInputStream, but with an image selected it fails, as opposed to doing the same thing with a xml File.

Any ideas what’s going on here?


Why does this fail with error Operation not permitted

 void loadImageFile(const File &f) //f is image file selected with native iOS document browser, path is valid
    std::unique_ptr<FileInputStream> inputStream  ( f.createInputStream() );

And this doesn’t:

 void loadXmlFile(const File &f) //f is xml file selected with native iOS document browser, path is valid
    auto xml = XmlDocument::parse(f);

Are you using getURLResults to retrieve the file selected from the FileChooser ? (instead of getResults)

No… should I?

I just tried this:

auto file = fileChooser.getURLResult().getLocalFile();
std::unique_ptr<FileInputStream> inputStream (file);

yields the same result. Or are you thinking of passing the URL result somewhere entirely different?

Yes, it makes a difference ( ), the InputStream should then be built with url.createInputStream.

1 Like

Awesome that did the trick! Knowing about SecurityBookmarks in the URL class helps! Thanks for the swift help