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 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

    VRoninV the_T 3 Replies Last reply
    0
    • K Kaluss

      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

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on 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 last edited by
        #3

        Then how I should send file binary data?

        1 Reply Last reply
        0
        • K Kaluss

          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

          VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on 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

            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

            the_T Offline
            the_T Offline
            the_
            wrote on last edited by
            #5

            @Kaluss
            Use multipart upload?

            -- No support in PM --

            1 Reply Last reply
            0
            • K Offline
              K Offline
              Kaluss
              wrote on 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

              the_T 1 Reply Last reply
              0
              • K Kaluss

                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

                the_T Offline
                the_T Offline
                the_
                wrote on 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 last edited by
                  #8

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

                  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