Results 1 to 10 of 10

Thread: QFTP resume download

  1. #1
    Join Date
    Feb 2008
    Posts
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QFTP resume download

    Hello,

    I'm working with QFtp and I have to implement a function that can allow user to resume an aborted download. I found the REST command from FTP RFC. I'm trying to use it with the "get" method but it doesn't work.

    Do you have any idea ?

    Here is my code :

    Qt Code:
    1. ftp->connectToHost(url.host(), url.port(21));
    2. ftp->login();
    3. reqRange="rest "+"100"; //In order to restart after 100 bytes, reqRange is a static buffer
    4. ftp->rawCommand(reqRange); //Without that line at the beginning, the download starts
    5. ftp->get(url.path(),file);
    To copy to clipboard, switch view to plain text mode 

    Thank you,

    Wagui
    Last edited by jpn; 13th March 2008 at 06:59. Reason: missing [code] tags

  2. #2
    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: QFTP resume download

    I think you have to send "RETR" command instead of using QFtp::get().

  3. #3
    Join Date
    Feb 2008
    Posts
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFTP resume download

    Thanks for your help.

    I have another questions : Do I have to use the passive mode (PASV command) ? Do you know if the get method send a PASV command behind ?

    I don't find any example of transmission.

    Thanks a lot !

    Wagui

  4. #4
    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: QFTP resume download

    It's best to take a network sniffer and see for yourself. Probably it doesn't.

  5. #5
    Join Date
    Feb 2008
    Posts
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFTP resume download

    I used a network sniffer and found that the get method sends a PASV command. So the transfer uses the FTP DATA. But when i use the rawCommand("RETR file.txt") method how do you retrieve the file from the FTP DATA.

    Thanks for your help.

    Wagui

  6. #6
    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: QFTP resume download

    Probably using QFtp::read().

  7. #7
    Join Date
    Feb 2008
    Posts
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFTP resume download

    I tried to use QFtp::read() method but this doesn't work, here is my code :

    Qt Code:
    1. ftp->rawCommand("TYPE I");
    2. ftp->rawCommand("PASV");
    3. reqRange="REST "+stailleEnreg;
    4. ftp->rawCommand(reqRange);
    5. reqRange="RETR "+url.path();
    6. ftp->rawCommand(reqRange);
    7.  
    8. char*bytes;
    9. bytes=(char*)malloc((tailleFichier-tailleEnreg+1)*sizeof(char));
    10.  
    11. ftp->read(bytes,tailleFichier-tailleEnreg);
    12. file->write(bytes,tailleFichier-tailleEnreg); //tailleFichier-tailleEnreg is the size of the end of the file.
    To copy to clipboard, switch view to plain text mode 
    When i use ethereal to see what happened : after the RETR the server doesn't return any response, he would have sent "125 Transfer starting"

    Thanks,

    Wagui
    Last edited by jpn; 13th March 2008 at 06:59. Reason: missing [code] tags

  8. #8
    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: QFTP resume download

    It doesn't work like that. You can't read immediately as there is nothing to be read. If the server doesn't respond to your command it probably means the ftp protocol assumes some other behaviour.

  9. #9
    Join Date
    Feb 2008
    Posts
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFTP resume download

    I think i 've found where is the problem. It seems that the get method from QFtp uses PASV command then listen and wait for a connection from the server. Then the data are transferred on this connection. I don't do that, and i think it's the reason of this problem.

    Perhabs some functions in the QtNetwork library can help me to do these low level operations.

    Wagui

  10. #10
    Join Date
    Feb 2008
    Posts
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QFTP resume download

    Hello,

    I don't find any method to make a connection on the data ftp. With the sniffer, i can display that :

    TYPE I
    200 Type set to I
    REST 471580
    350 Restarting at 471580
    PASV
    227 Entering Passive Mode (193,49,90,3,10,235);
    RETR /dossier/fichier.avi
    425 Can't open data connection

    Perhabs it's because i don't listen on a port on my computer. I didn't find any method to do that. Have you any idea about the problem ? Perhabs i forgot something important ...


    Thanks a lot

    Wagui

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.