1.)
Generating file (mFile)
QFile file(m_currentFile
->filename
);
Logger::getInstance()->Error(file.errorString());
}
if(!file.seek(segment_data->position)){
Logger::getInstance()->Error(file.errorString());
}
mFile = file.read(segment_data->segmentSize);
QFile file(m_currentFile->filename);
if(!file.open(QIODevice::ReadOnly)){
Logger::getInstance()->Error(file.errorString());
}
if(!file.seek(segment_data->position)){
Logger::getInstance()->Error(file.errorString());
}
mFile = file.read(segment_data->segmentSize);
To copy to clipboard, switch view to plain text mode
2.)
putting mFile to sendFile function
//code
strPage = m_httpClient->sendFileMultipart("url address" , request.toLatin1(), "att", mFileName, mFile);
//code
strPage = m_httpClient->sendFileMultipart("url address" , request.toLatin1(), "att", mFileName, mFile);
To copy to clipboard, switch view to plain text mode
2.
//send file function
///my code here
QString post_request
= postRequest;
if(!post_request.isEmpty()){
pr += "Content-Disposition: form-data; name=\"" + line.split('=')[0] + "\"\r\n\r\n";
pr += line.split('=')[1] + "\r\n";
pr += "--" + boundary + "\r\n";
}
data += pr;
}
data += file; //It crashes here
data += "\r\n";
data
+= QString("--" + boundary
+ "--\r\n").
toLatin1();
data += "\r\n";
//code
}
QString HttpClient::sendFileMultipart(const QString &url, const QByteArray &postRequest, const QString &fileInputName, const QString &fileName, const QByteArray &file){
///my code here
QString post_request = postRequest;
if(!post_request.isEmpty()){
QStringList req = post_request.split("&");
QByteArray pr;
foreach(QString line, req){
pr += "Content-Disposition: form-data; name=\"" + line.split('=')[0] + "\"\r\n\r\n";
pr += line.split('=')[1] + "\r\n";
pr += "--" + boundary + "\r\n";
}
data += pr;
}
data += file; //It crashes here
data += "\r\n";
data += QString("--" + boundary + "--\r\n").toLatin1();
data += "\r\n";
//code
}
To copy to clipboard, switch view to plain text mode
//Sorry I messed up file is not in base64 ..
But, I still dont know what makes crash
Bookmarks