UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Content exchange: Choose all file types from File Manager?

    Scheduled Pinned Locked Moved App Development
    html5content-hubpdffilemanagerfile manager
    9 Posts 4 Posters 870 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
      Reply
      • Reply as topic
      Log in to reply
      This topic has been deleted. Only users with topic management privileges can see it.
      • S Offline
        slimps
        last edited by

        I'm currently working on an HTML app which can open and display PDF files. I'm using the HTML5 FIle Reader API to open files; it works on Desktop, but not on Ubuntu Touch.

        When I try to open a file, it opens the "Choose from" panel, which tells me that "there aren't currently any apps installed that can provide this type of content". I found this a bit strange, since I thought I could choose from my filesystem directly.

        If it can be of any help, my HTML is: <input id="loadfile" type="file" />

        Is there a way I could load a file from my HTML app if there are no other applications to "provide" them? If not, would it be possible to make the File Manager app provide all types of files by default, so we can select files from the filesystem?


        This may be an alternate question (I'll open a different thread if requested), but in case the resolution of both problems are linked: Is there a way to make my HTML app accept PDF files from Content Exchange, so that other apps that want to send PDF files to other apps can show my app listed?

        CiberSheepC 1 Reply Last reply Reply Quote 0
        • CiberSheepC Offline
          CiberSheep
          last edited by

          I don't know how complete the ContentHub api for html5 apps is. You have information here: https://api-docs.ubports.com/sdk/apps/html5/ContentHub/index.html

          The message you get is because you have to specify the kind of files the app is expecting.

          I normally use a qtengineviewer so I can have more control: check https://gitlab.com/cibersheep/doc-renderer
          It is in alpha state though.

          Another planet, another time, another universe!

          1 Reply Last reply Reply Quote 0
          • CiberSheepC Offline
            CiberSheep @slimps
            last edited by CiberSheep

            @slimps said in Content exchange: Choose all file types from File Manager?:

            [...] Is there a way to make my HTML app accept PDF files from Content Exchange, so that other apps that want to send PDF files to other apps can show my app listed?

            Yes and no. You can be the ContentHub destination app of Documents file type, but not of pdf specifically.
            Some info: https://docs.ubports.com/en/latest/appdev/guides/contenthub.html

            An example: https://gitlab.com/TronFortyTwo/sturmreader/-/blob/master/contenthub.json

            (this file is used in the manifest of the app)

            Another planet, another time, another universe!

            S 1 Reply Last reply Reply Quote 0
            • S Offline
              slimps @CiberSheep
              last edited by

              @cibersheep Thanks for the links! I'll give them a look whenever I can.

              1 Reply Last reply Reply Quote 0
              • S Offline
                slimps
                last edited by

                I wanted to give it a try... but I can't even get to access the API! I'm trying to use the objects from the docs, but they don't seem to exist.

                Are you familiar with accessing the HTML5 API? Do you know if there's something I must to to have access to that API?

                CiberSheepC 1 Reply Last reply Reply Quote 0
                • CiberSheepC Offline
                  CiberSheep @slimps
                  last edited by CiberSheep

                  @slimps I've never tried it. I prefer to use an qml webview as I mentioned before

                  Let's see if someone else with more experience with html5 only apps can answer 😉

                  Another planet, another time, another universe!

                  1 Reply Last reply Reply Quote 0
                  • Schlicki2808S Offline
                    Schlicki2808
                    last edited by

                    I had a similar problem and I found a solution 🙂 At first, you have to add "content_exchange" to the list of the "policy_groups" in your apparmor file. Then, you'll get a list of apps when clicking on the file input. Then, you can use the change-event of the file input to read the contents of the chosen file. E.g.:

                    var input = document.getElementById("file");
                    if (input.files.length > 0) {
                        var reader = new FileReader();
                        reader.addEventListener("load", function() {
                            console.log(reader.result);
                        });
                        reader.readAsDataURL(input.files[0]);
                    }
                    

                    I hope this helps a bit.

                    S 1 Reply Last reply Reply Quote 1
                    • S Offline
                      slimps @Schlicki2808
                      last edited by

                      @schlicki2808 Amazing, it works! I was only lacking the policy group entry. Thank you so much!

                      LakotaubpL 1 Reply Last reply Reply Quote 1
                      • LakotaubpL Offline
                        Lakotaubp @slimps
                        last edited by

                        @slimps If you are happy plaes mark as solved to help ohers Thanks https://forums.ubports.com/topic/6311/how-to-ask-a-question-and-then-mark-it-as-solved

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post