Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. Streaming file content from webserver or something?
Forum Updated to NodeBB v4.3 + New Features

Streaming file content from webserver or something?

Scheduled Pinned Locked Moved Unsolved Brainstorm
15 Posts 3 Posters 3.6k Views 1 Watching
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    Do you mean you would like to somehow download a .dll and use it with your application ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    D 1 Reply Last reply
    0
    • SGaistS SGaist

      Hi,

      Do you mean you would like to somehow download a .dll and use it with your application ?

      D Offline
      D Offline
      davethedave
      wrote on last edited by
      #3

      @SGaist said in Streaming file content from webserver or something?:

      Hi,

      Do you mean you would like to somehow download a .dll and use it with your application ?

      Yeah how would i load the dll into memory (store it in a byte array), and how can i download it securely so it cant be stolen

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        Use a file server with login requirements.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        D 1 Reply Last reply
        0
        • SGaistS SGaist

          Use a file server with login requirements.

          D Offline
          D Offline
          davethedave
          wrote on last edited by davethedave
          #5

          @SGaist

          nice and what do i use in qt to acheive this?

          Currently have this code going on:
          QBuffer buffer;
          buffer.open(QBuffer::ReadWrite);
          buffer.write(reply->readAll());

          now my question is, how can i make sure the buffer stores in binary mode and how can i test by printing it out?

          JonBJ 1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            Do you mean implement a file server with Qt ?
            QBuffer uses a QByteArray internally which is what its name suggest: a byte array so whether you have text or binary doesn't matter at that level, it stores what you got from reply.

            What is reply by the way ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            D 1 Reply Last reply
            0
            • D davethedave

              @SGaist

              nice and what do i use in qt to acheive this?

              Currently have this code going on:
              QBuffer buffer;
              buffer.open(QBuffer::ReadWrite);
              buffer.write(reply->readAll());

              now my question is, how can i make sure the buffer stores in binary mode and how can i test by printing it out?

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #7

              @davethedave

              I'm currently retrieving the library from disk, but what if i want it to be secure and kept on a server somewhere?

              I don't understand what/why you're trying to achieve (many users' questions in this forum baffle me!), but just to be clear: you cannot download the content of a .DLL file into a program's (data) area and then have it run as code from there! OSes deliberately prevent you from doing this. Windows requires you to (dynamically) load a DLL for execution from a file on disk via ::LoadLibrary().

              If you are trying to prevent some kind of copying, I suppose you could download it to a file first and then dynamically load that (and magically delete it on exit, and hope it can't be copied while it's on local disk), but it all seems a bit pointless. If you are the the author of the DLL it would be more usual to put some kind of security into the code, such as requiring the calling program to pass some kind of "token" to it which it checks for before executing its functions.

              1 Reply Last reply
              1
              • SGaistS SGaist

                Do you mean implement a file server with Qt ?
                QBuffer uses a QByteArray internally which is what its name suggest: a byte array so whether you have text or binary doesn't matter at that level, it stores what you got from reply.

                What is reply by the way ?

                D Offline
                D Offline
                davethedave
                wrote on last edited by davethedave
                #8

                @SGaist

                QNetworkAccessManager* m_NetworkMngr = new QNetworkAccessManager();
                QNetworkReply *reply = m_NetworkMngr->get(QNetworkRequest(QUrl("http://url.com/file")));

                but the problem is I'm unable to print the buffer, it doesnt have the data stored in there. but if i print to a file then it works

                So what i need to do now is:
                QNetworkAccessManager* m_NetworkMngr = new QNetworkAccessManager();
                QNetworkReply *reply = m_NetworkMngr->get(QNetworkRequest(QUrl("http://url.com/file)));
                QEventLoop loop;
                connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
                loop.exec();
                QUrl aUrl("http://url.com/file");
                QFileInfo fileInfo=aUrl.path();
                QFile file2("c:\"+fileInfo.fileName());
                file2.open(QIODevice::WriteOnly);
                file2.write(reply->readAll());
                QBuffer buffer;
                buffer.open(QBuffer::ReadWrite);
                buffer.write(reply->readAll());
                buffer.close();
                qDebug() << buffer.buffer();

                Okay so now it prints the contents of my file, but how can i make sure its in binary mode? is there something i can do to my file before i upload it, i want it to do the equivelant of std::ios::binary

                JonBJ 1 Reply Last reply
                0
                • D davethedave

                  @SGaist

                  QNetworkAccessManager* m_NetworkMngr = new QNetworkAccessManager();
                  QNetworkReply *reply = m_NetworkMngr->get(QNetworkRequest(QUrl("http://url.com/file")));

                  but the problem is I'm unable to print the buffer, it doesnt have the data stored in there. but if i print to a file then it works

                  So what i need to do now is:
                  QNetworkAccessManager* m_NetworkMngr = new QNetworkAccessManager();
                  QNetworkReply *reply = m_NetworkMngr->get(QNetworkRequest(QUrl("http://url.com/file)));
                  QEventLoop loop;
                  connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
                  loop.exec();
                  QUrl aUrl("http://url.com/file");
                  QFileInfo fileInfo=aUrl.path();
                  QFile file2("c:\"+fileInfo.fileName());
                  file2.open(QIODevice::WriteOnly);
                  file2.write(reply->readAll());
                  QBuffer buffer;
                  buffer.open(QBuffer::ReadWrite);
                  buffer.write(reply->readAll());
                  buffer.close();
                  qDebug() << buffer.buffer();

                  Okay so now it prints the contents of my file, but how can i make sure its in binary mode? is there something i can do to my file before i upload it, i want it to do the equivelant of std::ios::binary

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #9

                  @davethedave
                  If you can "print to a file" then you can "print from buffer".

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    davethedave
                    wrote on last edited by
                    #10

                    Yea, but i want to split the file into an array of bytes which i could do with fstream std::ios::binary, but now i cant..

                    JonBJ 1 Reply Last reply
                    0
                    • D davethedave

                      Yea, but i want to split the file into an array of bytes which i could do with fstream std::ios::binary, but now i cant..

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #11

                      @davethedave
                      Really don't know what you mean. http://doc.qt.io/qt-5/qiodevice.html#readAll, which is what you're using on your QNetworkReply, already returns a QByteArray, and there's no binary-to-text translation going on. Can't see what you'd do with your fstream std::ios::binary which is not just as easy in Qt functions.

                      D 1 Reply Last reply
                      1
                      • JonBJ JonB

                        @davethedave
                        Really don't know what you mean. http://doc.qt.io/qt-5/qiodevice.html#readAll, which is what you're using on your QNetworkReply, already returns a QByteArray, and there's no binary-to-text translation going on. Can't see what you'd do with your fstream std::ios::binary which is not just as easy in Qt functions.

                        D Offline
                        D Offline
                        davethedave
                        wrote on last edited by davethedave
                        #12

                        @JonB said in Streaming file content from webserver or something?:

                        @davethedave
                        Really don't know what you mean. http://doc.qt.io/qt-5/qiodevice.html#readAll, which is what you're using on your QNetworkReply, already returns a QByteArray, and there's no binary-to-text translation going on. Can't see what you'd do with your fstream std::ios::binary which is not just as easy in Qt functions.

                        When i print the buffer its in plain text it should be like
                        "\0x80\0x90..."

                        JonBJ 1 Reply Last reply
                        0
                        • D davethedave

                          @JonB said in Streaming file content from webserver or something?:

                          @davethedave
                          Really don't know what you mean. http://doc.qt.io/qt-5/qiodevice.html#readAll, which is what you're using on your QNetworkReply, already returns a QByteArray, and there's no binary-to-text translation going on. Can't see what you'd do with your fstream std::ios::binary which is not just as easy in Qt functions.

                          When i print the buffer its in plain text it should be like
                          "\0x80\0x90..."

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by
                          #13

                          @davethedave
                          Having to guess here. Are you talking about the particular way the line

                          qDebug() << buffer.buffer();
                          

                          shows its output??

                          1 Reply Last reply
                          0
                          • D Offline
                            D Offline
                            davethedave
                            wrote on last edited by
                            #14

                            Right so its currently showing output in plain text
                            "Hello world"
                            how can i print it as an arab of byte / store it

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #15

                              You can get get the hex values with QByteArray::toHex.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              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