Results 1 to 16 of 16

Thread: How to code a (simple ?) cUrl command in Qt ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2010
    Posts
    12
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default How to code a (simple ?) cUrl command in Qt ?

    Hello !
    I have a simple cUrl command that i need to code in a Qt app:
    curl -u user:pass -F "filename=test.txt" -F "fname=@foo.txt" http://www.myserver.com/fileupload.htm

    (Not that i know much of cUrl other then it can do MUCH more :-) )

    So this should fill out a form with a "test.txt" and upload a file while providing basic user/pass credentials.

    Could i do this whith built-in Qt functions or do i need to run the cUrl command line binary OR to use the cUrl library ?

    Any help is really appreciated :-)

    Greetings,

    Nils

  2. #2
    Join Date
    Jun 2010
    Posts
    12
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to code a (simple ?) cUrl command in Qt ?

    Any help ?
    It seems IF i code the curl command line from above in C++ code using libcurl it wuld be something like this (for the two -F parameters):


    curl_formadd(&formpost,
    &lastptr,
    CURLFORM_COPYNAME, "sendfile",
    CURLFORM_FILE, "postit2.c",
    CURLFORM_END);

    /* Fill in the filename field */
    curl_formadd(&formpost,
    &lastptr,
    CURLFORM_COPYNAME, "filename",
    CURLFORM_COPYCONTENTS, "postit2.c",
    CURLFORM_END);


    But i'd like to avoid to "yet use another lib" if i could do this with Qt native stuff.
    Do you have any hint to do this without curl CLI or libcurl ?

    Nils

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to code a (simple ?) cUrl command in Qt ?

    What kind of help do you expect from us?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jun 2010
    Posts
    12
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to code a (simple ?) cUrl command in Qt ?

    Hi !
    Sorry if i failed to make myself clear.
    I need some hint / help / sample code that only uses Qt native commands and that has the same result as the curl command line that i posted. (Or presumably as the sniplet of using curl.h).

    I fail to explain it more simple.

    Greetings,

    Nils

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to code a (simple ?) cUrl command in Qt ?

    Hmmm... so you want a complete solution for the task? It's not 5 lines of code, you know...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Jun 2010
    Posts
    12
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to code a (simple ?) cUrl command in Qt ?

    Hi wysota !
    Its not about what i want but what someone is willing to do.
    At least i know that it is NOT 5 lines of code :-)

    I am really not new to Qt but i NEVER did web stuff...
    I assume that the QNetworkAccessManager may be the thing to check out but it looks so complex that a simple "No" or "Yes" would already help. And if someone feels like it i am sure that there are some key aspects that could help me tremendously.
    But with your reputation here i already feel sheepish to explain to YOU you help can look.
    I'll take what i get, networkwise i really start at ZERO.
    And if you tell me not to do it as libcurl is much better to do it then thats it.
    (provided that you give a minimum of reasoning, i would HATE to incorporate another huge lib if i do not need to).

    Greetings,

    Nils

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to code a (simple ?) cUrl command in Qt ?

    Quote Originally Posted by nils_heidorn View Post
    I assume that the QNetworkAccessManager may be the thing to check out but it looks so complex that a simple "No" or "Yes" would already help.
    Yes

    And if someone feels like it i am sure that there are some key aspects that could help me tremendously.
    The key aspect is definitely encoding the form. The rest is easily handled by QNetworkRequest.

    And if you tell me not to do it as libcurl is much better to do it then thats it.
    Well... if you like reinventing the wheel then that's fine with me If size is an issue and you're using Qt anyway then indeed not using 3rd party libs is an advantage.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. The following user says thank you to wysota for this useful post:

    nils_heidorn (30th August 2013)

  9. #8
    Join Date
    Jun 2010
    Posts
    12
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to code a (simple ?) cUrl command in Qt ?

    Hi !

    Thanks again :-)
    Ooookay, if you feel like it, may help me out with encoding the form, right now i do not even know what that may means (well besides foggy ideas) :-)

    And for re-inventing the wheel:
    Of course if it is too hard doing it the "Qt way" then i will use curl, but i hoped that the curl 30 liner could be done at least with a Qt 50 liner or so...

    Its not about reinventing the wheel but about having to get a spare tire and learning that there already is one hidden deep in the trunk that is a BIT hard to get at ;-)


    Greetings,

    Nils

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to code a (simple ?) cUrl command in Qt ?

    Quote Originally Posted by nils_heidorn View Post
    Ooookay, if you feel like it, may help me out with encoding the form, right now i do not even know what that may means (well besides foggy ideas) :-)
    Search the web for "http form encoding"
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #10
    Join Date
    Jun 2010
    Posts
    12
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to code a (simple ?) cUrl command in Qt ?

    Hi !
    After i knew what to search for i found at least 2 threads that might help me. Now i have to wait for the test server to be up and running to try out stuff :-)

    AM i allowed to post links to other forums here ?
    I'd love too, so others can follow the same path ...

    Just let me know.

    Greetings,

    Nils

  12. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to code a (simple ?) cUrl command in Qt ?

    Quote Originally Posted by nils_heidorn View Post
    AM i allowed to post links to other forums here ?
    I'd love too, so others can follow the same path ...
    Sure, no problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #12
    Join Date
    Jun 2010
    Posts
    12
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to code a (simple ?) cUrl command in Qt ?

    Hi !

    So here are the links to posts in other forums. I HOPE they will help me, cannot try right now as the test server is not yet up.
    Please let me know if you do *not* think that those links will be helpful.

    http://qt-project.org/forums/viewthread/11361
    http://stackoverflow.com/questions/2...kaccessmanager


    Greetings,
    Nils

Similar Threads

  1. Simple code causes segmentation fault...in debug
    By Raccoon29 in forum Qt Programming
    Replies: 18
    Last Post: 22nd December 2009, 09:15
  2. Replies: 3
    Last Post: 11th December 2009, 17:13
  3. Replies: 2
    Last Post: 9th November 2009, 09:31
  4. running shell command from C++ code problem
    By alex chpenst in forum Qt Programming
    Replies: 4
    Last Post: 31st July 2008, 10:41
  5. Creating simple text editor from the eamples code
    By overcast in forum Qt Programming
    Replies: 4
    Last Post: 14th February 2007, 15:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.