How to upload a break off file?
I want upload a break off file.
- There is a file, size is 10MB.
- upload the file with 5MB to server, and close connect.
- upload the file from last point(5MB) to server.
How should I do in step 3?
Thanks for your help.
Sorry, I cann't reply this post. I have add my reply in here:
Yes, When I do this using QHttpMultiPart and QFile, the program cann't stop in the last.
I don't know why, here is the code and thanks for your reply:
QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
textPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name="text""));
imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name="image""));
QFile *file = new QFile("image.jpg");
file->setParent(multiPart); // we cannot delete the file now, so delete it with the multiPart
QNetworkReply *reply = manager.post(request, multiPart);
multiPart->setParent(reply); // delete the multiPart with the reply
// here connect signals etc.
QObject::connect(&timer,SIGNAL(timeout()), &loop, SLOT(quit()));
int updateProgressTimes = 0;
loop.exec(); // in the last, this exec cann't exit, and cpu is 100%
First step: upload with a header. In the header you will explain that it's a new file, size and name.
Second step: in the header you will explain size and name and in this case it's in append mode.