Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Share file

Share file

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
7 Posts 2 Posters 1.9k Views
  • 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.
  • canellasC Offline
    canellasC Offline
    canellas
    wrote on last edited by
    #1

    Hi!

    I wrote an app (with a lot of help from many guys here!) that records an audio file.

    Now I need to allow the access to the file outside the application private directories, so that the user can, for instance, send it by email to someone else.

    An important detail is that I tried to save the file in all the values of
    enum QStandardPaths::StandardLocation, but only QStandardPaths::TempLocation worked, in Android as well as in iPhone.

    Does anyone have an idea of how can I do that?

    Thanks!

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Tschikkn
      wrote on last edited by
      #2

      Hi!

      I do not know the specification of Android or iPhones, but you may have a look at the output of the standard-paths provided by Qt.

      Code-Snippet:

      QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
      
      if ( !dir.exists() ) {
          dir.mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
      }
      
      QString theDataDir =  QStandardPaths::writableLocation(QStandardPaths::DataLocation);
      
      qDebug() <<  theDataDir;
      

      I'm using this path for my apps on linux-based systems. Well, my tries, not apps...but anyway it works :)

      1 Reply Last reply
      0
      • canellasC Offline
        canellasC Offline
        canellas
        wrote on last edited by
        #3

        Tschikkn,

        Thanks for your time!

        What a coincidence! I was reading (again) the help for QDir, and I saw that the directory may not exist yet. So I tried the almost exact the same code you suggested, and now the audio file is being recorded at QStandardPaths::MusicLocation.

        That`s great!

        However, I still have the problem of accessing the file through another application... any ideas?

        Thanks!

        1 Reply Last reply
        0
        • T Offline
          T Offline
          Tschikkn
          wrote on last edited by
          #4

          Hi!

          Could you specify "problem of accessing the file"? What exactly does not work as expected? Try to open it with QFile to get an error message.

          Does the other application use the same user-rights as your first one?

          1 Reply Last reply
          0
          • canellasC Offline
            canellasC Offline
            canellas
            wrote on last edited by
            #5

            Thanks again for your time, Tschikkn!

            The audio file is now being saved at QStandardPaths::MusicLocation, but, AFAIK, no other app can access this file. Well, at least the audio player I tried did not "see" it.

            So, my problem is: how to allow another app, like Telegram, GMail, etc., to access this file?

            Thanks

            1 Reply Last reply
            0
            • T Offline
              T Offline
              Tschikkn
              wrote on last edited by
              #6

              As already mentioned I do not know the environments you are working in. But it sounds like a permission problem or an incorrect file.

              If you do have terminal access to your android device you could try to get these informations with

              ls -lha /path/to/file/audiofile.extension
              

              Giving an output like
              -rw-rw-r-- 1 tschikkn tschikkn 0 Sep 30 23:41 test.file
              See archwiki:File permissions for more info.

              And there are perhaps informations on it using

              file /path/to/file/audiofile.extension
              

              Without terminal access you may run these commands through QProcess.

              I hope there's enough linux in android to give an output :) Perhaps another member could help you more.

              1 Reply Last reply
              0
              • canellasC Offline
                canellasC Offline
                canellas
                wrote on last edited by
                #7

                I wrote a piece of code to copy the file to QStandardPaths::DownloadLocation, and there were no errors, but still no app, either in Android or iPhone can access the file.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved