|
@@ -53,13 +53,16 @@ void QtFtp::putFile(const QString &fileName, const QString &farPath)
|
|
|
m_isFinished = false;
|
|
|
m_result = false;
|
|
|
|
|
|
- QFile file(fileName);
|
|
|
- file.open(QFile::ReadOnly);
|
|
|
- QByteArray ba = file.readAll();
|
|
|
- file.close();
|
|
|
+ m_fileUpload.setFileName(fileName);
|
|
|
+ if(!m_fileUpload.open(QFile::ReadOnly))
|
|
|
+ {
|
|
|
+ LOG_WARN("open file failed , file path : " + fileName);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
m_url.setPath(farPath);
|
|
|
- m_reply = m_manager.put(QNetworkRequest(m_url),ba);
|
|
|
+ m_reply = m_manager.put(QNetworkRequest(m_url),&m_fileUpload);
|
|
|
/* 将信号进行一次转发 */
|
|
|
connect(m_reply,SIGNAL(uploadProgress(qint64,qint64)),this,SIGNAL(signal_uploadProgress(qint64,qint64)));
|
|
|
/* 连接信号和槽 */
|
|
@@ -224,6 +227,7 @@ void QtFtp::do_uploadFinished()
|
|
|
LOG_WARN("FTP upload failed : " + m_reply->errorString());
|
|
|
emit signal_uploadState(false);
|
|
|
}
|
|
|
+ m_fileUpload.close();
|
|
|
m_reply->deleteLater();
|
|
|
m_reply = nullptr;
|
|
|
m_isFinished = true;
|
|
@@ -283,8 +287,8 @@ void QtFtp::do_downloadFinished()
|
|
|
{
|
|
|
while(!m_reply->atEnd())
|
|
|
{
|
|
|
- /* 每次读取100MB */
|
|
|
- QByteArray data = m_reply->read(104857600);
|
|
|
+ /* 每次读取10MB */
|
|
|
+ QByteArray data = m_reply->read(10485760);
|
|
|
quint64 writenBytes = m_file.write(data);
|
|
|
LOG_DEBUG("write file : " + QString::number(writenBytes));
|
|
|
if(writenBytes != data.size())
|