QT upload (PUT) a file
You should make some code modifications:
file.open(QIODevice::ReadOnly);//add next linesfilePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/zip")); //or whatever type of your file.filePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"file\""));filePart.setHeader(QNetworkRequest::ContentLengthHeader, file.size());//and your other codefilePart.setBodyDevice(file);multiPart.append(filePart);
And also take attention that with curl
you make POST
request but with Qt
- put
. So also replace last line with this:
QNetworkReply * reply = mgr.post(req, &multiPart);