Results 1 to 5 of 5

Thread: Download file from X to Y bytes

  1. #1
    Join Date
    Dec 2010
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Download file from X to Y bytes

    I have couple of doubts regarding downloading of file using QT

    1. Is it possible to get the size of file before start downloading ?
    2. Also is it possible to download only x to y bytes from a file ?

    Thanks in advance.

  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: Download file from X to Y bytes

    It depends if the server you are downloading from (assuming you want to use HTTP) supports such operations. There is nothing preventing you from issuing the right commands in the Qt client. The server may simply not understand them or decline to use them.
    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.


  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Download file from X to Y bytes

    Assuming HTTP/HTTPS:
    1. Issue a HEAD request and look at the Content-Length: header
    2. If the HEAD request headers contains the "Accept-Ranges: bytes" header then you might be able to GET a specified range of bytes with the "Range: bytes=500-999" (e.g. second 500 bytes) header.
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

  4. #4
    Join Date
    Apr 2011
    Posts
    61
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Download file from X to Y bytes

    ChrisW67, I want to do some download things like this, Qt have specific functions for this GET with range? Or we need to build the request and send ?

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Download file from X to Y bytes

    You have to set the request headers yourself and then use the QNetworkAccessManager to send the request
    Last edited by ChrisW67; 12th May 2011 at 06:55.

  6. The following user says thank you to ChrisW67 for this useful post:

    rsilva (12th May 2011)

Similar Threads

  1. Download file to QString
    By Chiggins in forum Qt Programming
    Replies: 2
    Last Post: 25th June 2010, 20:16
  2. Download File
    By BalaQT in forum Qt Programming
    Replies: 2
    Last Post: 13th February 2010, 10:53
  3. reading bytes out of a file
    By priceey in forum Qt Programming
    Replies: 7
    Last Post: 6th October 2009, 17:55
  4. Reading and writing bytes in file
    By DiamonDogX in forum Qt Programming
    Replies: 2
    Last Post: 20th May 2009, 21:25
  5. reading 4-bytes integer from binary file
    By maka in forum Qt Programming
    Replies: 8
    Last Post: 12th May 2009, 06:57

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.