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.
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.
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.
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.
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 ?
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 05:55.
rsilva (12th May 2011)
Bookmarks