Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 6

Qt-interest Archive, March 2007
copy large files with QUrlOperator


Message 1 in thread

Hello list,

i've got a working QUrlOperator copy function which crashes with large 
files. Qt tries to buffer the whole file first before starting to write 
it down to the hard disc.

void CSCopyProgress::slot_FileCopy_dataTransferProgress( int 
p_bytesDone, int p_bytesTotal, QNetworkOperation * op ) {
if( op->operation() == QNetworkProtocol::OpGet ) {
  cout << "GET" << endl;
} else if( op->operation() == QNetworkProtocol::OpPut ) {
  cout << "   PUT" << endl;
}


With smaller files this results in some GET outputs, followed by PUT 
outputs. With large files i only get the GET outputs, during reading the 
program crashes.


Anyone has a solution for me?

Greetz,
Sven

(sorry for my bad english)

--
 [ signature omitted ] 

Message 2 in thread

Sven Lepiorz schrieb:
> Hello list,
> 
> i've got a working QUrlOperator copy function which crashes with large
> files. Qt tries to buffer the whole file first before starting to write

From the Qt 4 "porting guidelines": "The QUrlOperator class is no longer
part of the public Qt API."

So I assume you are using Qt 3 ;) (Or the QUrl3Operator).

In any case the preferred method would probably be to implement your own
streaming of large files. The Qt 4 porting guidelines recommend using
QFtp or QHttp directly (or QFile).

For example some (or most) HTTP servers/clients support something called
"HTTP chunking" where you can send data over HTTP without specifying the
content length. (I have just little experience with that in the context
of gSoap, a C/C++ SOAP implementation which supports file streaming
using "HTTP chunking".

On the other side I don't know wheter QHttp supports "chunking", how to
enable it etc. (I have never used QHttp myself).

QFtp should actually work with large files since (at least the protocol)
FTP is designed to handle large files.

And with QFile it should be fairly easy to implement your own chunking:
QIODevice::seek should come handy here: read blocks of say 1 MByte and
in each read you "seek" to the proper position in the input file. Then
append the chunk to the output file.

But apart from all that: QUrlOperator should off course not crash when
dealing with (too) large files, that would be a bug in Qt.

Cheers, Oliver

--
 [ signature omitted ]