Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Sending Excel file via post script.

Sending Excel file via post script.

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 1.7k 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.
  • K Offline
    K Offline
    Kaluss
    wrote on 30 Mar 2017, 13:54 last edited by
    #1

    Hi,
    I want to send a excel file via post:

       QNetworkRequest request( QUrl( "my url") );
    
    
       request.setHeader( QNetworkRequest::ContentTypeHeader,
    
                          "application/x-www-form-urlencoded" );
    
       QUrlQuery params;
    
       params.addQueryItem( "username", accountName );
    
    
       params.addQueryItem( "file", reportFile->readAll() );
    
    
       QNetworkAccessManager manager;
    
    
       QNetworkReply *reply = manager.post( request, params.query().toUtf8() );
    

    But I get the upload error .
    The post script is tested and works fine.
    Can anybody check if I do something wrong there?
    Any hints would be priceless.

    Best regards,
    Tomek

    V T 3 Replies Last reply 30 Mar 2017, 14:15
    0
    • K Kaluss
      30 Mar 2017, 13:54

      Hi,
      I want to send a excel file via post:

         QNetworkRequest request( QUrl( "my url") );
      
      
         request.setHeader( QNetworkRequest::ContentTypeHeader,
      
                            "application/x-www-form-urlencoded" );
      
         QUrlQuery params;
      
         params.addQueryItem( "username", accountName );
      
      
         params.addQueryItem( "file", reportFile->readAll() );
      
      
         QNetworkAccessManager manager;
      
      
         QNetworkReply *reply = manager.post( request, params.query().toUtf8() );
      

      But I get the upload error .
      The post script is tested and works fine.
      Can anybody check if I do something wrong there?
      Any hints would be priceless.

      Best regards,
      Tomek

      V Offline
      V Offline
      VRonin
      wrote on 30 Mar 2017, 14:15 last edited by
      #2

      @Kaluss said in Sending Excel file via post script.:

      params.addQueryItem( "file", reportFile->readAll() );

      What is this supposed to do?! doesn't look right to me

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Kaluss
        wrote on 30 Mar 2017, 14:17 last edited by
        #3

        Then how I should send file binary data?

        1 Reply Last reply
        0
        • K Kaluss
          30 Mar 2017, 13:54

          Hi,
          I want to send a excel file via post:

             QNetworkRequest request( QUrl( "my url") );
          
          
             request.setHeader( QNetworkRequest::ContentTypeHeader,
          
                                "application/x-www-form-urlencoded" );
          
             QUrlQuery params;
          
             params.addQueryItem( "username", accountName );
          
          
             params.addQueryItem( "file", reportFile->readAll() );
          
          
             QNetworkAccessManager manager;
          
          
             QNetworkReply *reply = manager.post( request, params.query().toUtf8() );
          

          But I get the upload error .
          The post script is tested and works fine.
          Can anybody check if I do something wrong there?
          Any hints would be priceless.

          Best regards,
          Tomek

          V Offline
          V Offline
          VRonin
          wrote on 30 Mar 2017, 14:25 last edited by
          #4

          @Kaluss said in Sending Excel file via post script.:

          The post script is tested and works fine.

          Could you show us your script?

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          0
          • K Kaluss
            30 Mar 2017, 13:54

            Hi,
            I want to send a excel file via post:

               QNetworkRequest request( QUrl( "my url") );
            
            
               request.setHeader( QNetworkRequest::ContentTypeHeader,
            
                                  "application/x-www-form-urlencoded" );
            
               QUrlQuery params;
            
               params.addQueryItem( "username", accountName );
            
            
               params.addQueryItem( "file", reportFile->readAll() );
            
            
               QNetworkAccessManager manager;
            
            
               QNetworkReply *reply = manager.post( request, params.query().toUtf8() );
            

            But I get the upload error .
            The post script is tested and works fine.
            Can anybody check if I do something wrong there?
            Any hints would be priceless.

            Best regards,
            Tomek

            T Offline
            T Offline
            the_
            wrote on 30 Mar 2017, 15:17 last edited by
            #5

            @Kaluss
            Use multipart upload?

            -- No support in PM --

            1 Reply Last reply
            0
            • K Offline
              K Offline
              Kaluss
              wrote on 3 Apr 2017, 09:01 last edited by
              #6

              You are right, but I don't have any experience with multipart sending.
              Could anybody give ma a hint how to prepare that?

              I have to send to parameters:
              1)Username as a string
              2)File as a binary data

              How to prepare particular parts?

              BR/T

              T 1 Reply Last reply 3 Apr 2017, 11:21
              0
              • K Kaluss
                3 Apr 2017, 09:01

                You are right, but I don't have any experience with multipart sending.
                Could anybody give ma a hint how to prepare that?

                I have to send to parameters:
                1)Username as a string
                2)File as a binary data

                How to prepare particular parts?

                BR/T

                T Offline
                T Offline
                the_
                wrote on 3 Apr 2017, 11:21 last edited by
                #7

                @Kaluss

                Just have a look at the documentation at http://doc.qt.io/qt-5/qhttpmultipart.html

                There is an example how to post data and file to a Web page

                -- No support in PM --

                1 Reply Last reply
                2
                • K Offline
                  K Offline
                  Kaluss
                  wrote on 4 Apr 2017, 07:03 last edited by
                  #8

                  Documentation helped me a lot, but wireshark was also very helpful.

                  1 Reply Last reply
                  0

                  1/8

                  30 Mar 2017, 13:54

                  • Login

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