I want to get the file size of a file hosted on Amazon S3 in my Qt app.
The code below works great for non-S3 files, but for signed S3 links it prints out QVariant(Invalid)
It seems that Content-Length isn't in the S3 HTTP header ... so how do I get the file size?
void MainWindow::requestFileSize(QString url)
{
QNetworkRequest req;
m_netmanager = new QNetworkAccessManager(this);
QUrl strict_url = QUrl::fromEncoded(url.toStdString().c_str(),QUrl::StrictMode);
req.setUrl(strict_url);
m_reply = m_netmanager->head(req);
connect(m_reply, SIGNAL(metaDataChanged()), this, SLOT(fileSize()));
}
void MainWindow::fileSize()
{
qDebug() << "Content Length: " << m_reply->header(QNetworkRequest::ContentLengthHeader);
}