Commit aef57757 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

If no download URL is known, try an export URL

There are cases where the file's MIME type is a regular file, e.g. image/png
but there is no download URL. Try the export URL for this MIME type, too.
parent b4715ea9
Pipeline #238944 passed with stage
in 37 seconds
......@@ -120,6 +120,15 @@ QUrl GDriveHelper::convertFromGDocs(KGAPI2::Drive::FilePtr &file)
return file->downloadUrl();
}
QUrl GDriveHelper::downloadUrl(const KGAPI2::Drive::FilePtr &file)
{
if (file->downloadUrl().isValid()) {
return file->downloadUrl();
}
return file->exportLinks().value(file->mimeType());
}
// Currently unused, see https://phabricator.kde.org/T3443
/*
KIO::UDSEntry GDriveHelper::trash()
......
......@@ -19,6 +19,8 @@ namespace GDriveHelper
QUrl convertFromGDocs(KGAPI2::Drive::FilePtr &file);
QUrl downloadUrl(const KGAPI2::Drive::FilePtr &file);
KIO::UDSEntry trash();
QString elideToken(const QString &token);
......
......@@ -982,7 +982,7 @@ void KIOGDrive::get(const QUrl &url)
if (GDriveHelper::isGDocsDocument(file)) {
downloadUrl = GDriveHelper::convertFromGDocs(file);
} else {
downloadUrl = file->downloadUrl();
downloadUrl = GDriveHelper::downloadUrl(file);
}
mimeType(file->mimeType());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment