QT 從http頭中讀取檔案資訊
阿新 • • 發佈:2019-02-05
void MainWindow::unsupportedContent(QNetworkReply *reply) { qDebug() << "Left click - download!"; qDebug() << "Bytes to download: " << reply->bytesAvailable(); QString str = reply->rawHeader("Content-Disposition"); QString end = str.mid(22); end.chop(1); qDebug() << "File name: " << end; qDebug() << "File type: " << reply->rawHeader("Content-Type"); qDebug() << "File size (bytes): " << reply->bytesAvailable(); QString defaultFileName = QFileInfo(end).fileName(); QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), defaultFileName); }