diff --git a/src/drive/fileabstractuploadjob.cpp b/src/drive/fileabstractuploadjob.cpp --- a/src/drive/fileabstractuploadjob.cpp +++ b/src/drive/fileabstractuploadjob.cpp @@ -81,9 +81,12 @@ return QByteArray(); } - const QMimeDatabase db; - const QMimeType mime = db.mimeTypeForFileNameAndData(filePath, &file); - contentType = mime.name(); + if (contentType.isEmpty()) { + const QMimeDatabase db; + const QMimeType mime = db.mimeTypeForFileNameAndData(filePath, &file); + contentType = mime.name(); + qCDebug(KGAPIDebug) << "Determined content type" << contentType << "for" << filePath; + } file.reset(); QByteArray output = file.readAll(); @@ -97,14 +100,16 @@ const FilePtr &metaData, QString &boundary) { - QString fileContentType; + QString fileContentType = metaData->mimeType(); QByteArray fileContent; fileContent = readFile(filePath, fileContentType); if (fileContent.isEmpty()) { return QByteArray(); } + qCDebug(KGAPIDebug) << "Setting content type" << fileContentType << "for" << filePath; + // Wannabe implementation of RFC2387, i.e. multipart/related QByteArray body; QFileInfo finfo(filePath); @@ -162,6 +167,7 @@ if (metaData.isNull()) { query.addQueryItem(QStringLiteral("uploadType"), QStringLiteral("media")); + contentType = metaData->mimeType(); rawData = readFile(filePath, contentType); if (rawData.isEmpty()) { processNext();