Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › FileUtils doesn't seem to work (Felgo 3)

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #24981

    Makoren

    I’m trying to load a JSON file that I’ve stored locally. To load this file I’ve tried to use FileUtils.readFile, but I get the following error:

    TypeError: Property 'readFile' of object [object Object] is not a function

    This seems to happen in the online examples too, and happens on other FileUtils functions too. Is this a bug, and if it is, what’s the workaround?

    #24982

    Makoren

    The workaround appears to either use XMLHttpRequest for plain text, or a native C++ function for binary files, thanks to a bit of searching on Stack Overflow. I get a scary warning in the console if I use XMLHttpRequest however.

    I’d like to know if FileUtils is working or not. Is it working in Felgo 4 at least?

    #24985

    Alex
    Felgo Team

    Hi,

    could you post a minimal runnable example that reproduces the problem? Also, what type of file are you trying to open? What platform are you testing on?

    Best,
    Alex

    #24986

    Makoren

    Every example on this page throws that error in the web editor: https://felgo.com/doc/felgo-fileutils/

    I’ve personally tested the FileUtils class on mobile and desktop through the live client.

    #24987

    Günther
    Felgo Team

    Hi Makoren,

    Felgo 4 changed how singletons like NativeUtils and FileUtils behave. In Felgo 3, it wasn’t possible to use the uppercase type name to work with the class. Instead, there are lowercase nativeUtils and fileUtils context properties registered with the QML engine.

    When you port Felgo 4 snippets from the documentation to Felgo 3, it is thus required to change function calls on these classes to the lowercase version:
    E.g. use fileUtils.openFile(pdfResource.storagePath) instead of FileUtils.openFile(pdfResource.storagePath).

    Enumeration values are available uppercase on both Felgo versions, e.g. FileUtils.DocumentsLocation.

    Best,
    Günther

    #24988

    Makoren

    Using the lowercase fileUtils works wonderfully, thanks!

    Looking forward to when Felgo 4 can use the game related QML types.

Viewing 6 posts - 1 through 6 (of 6 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded