mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-29 11:48:05 -06:00
Allow WebAPI to specify filename and mime type for result data
PR #20377.
This commit is contained in:
committed by
GitHub
parent
8ef99b336c
commit
60bb819e2e
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2018, 2022 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2018-2024 Vladimir Golovnev <glassez@yandex.ru>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -37,12 +37,19 @@
|
||||
|
||||
#include "apierror.h"
|
||||
|
||||
void APIResult::clear()
|
||||
{
|
||||
data.clear();
|
||||
mimeType.clear();
|
||||
filename.clear();
|
||||
}
|
||||
|
||||
APIController::APIController(IApplication *app, QObject *parent)
|
||||
: ApplicationComponent(app, parent)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant APIController::run(const QString &action, const StringMap ¶ms, const DataMap &data)
|
||||
APIResult APIController::run(const QString &action, const StringMap ¶ms, const DataMap &data)
|
||||
{
|
||||
m_result.clear(); // clear result
|
||||
m_params = params;
|
||||
@@ -79,20 +86,22 @@ void APIController::requireParams(const QVector<QString> &requiredParams) const
|
||||
|
||||
void APIController::setResult(const QString &result)
|
||||
{
|
||||
m_result = result;
|
||||
m_result.data = result;
|
||||
}
|
||||
|
||||
void APIController::setResult(const QJsonArray &result)
|
||||
{
|
||||
m_result = QJsonDocument(result);
|
||||
m_result.data = QJsonDocument(result);
|
||||
}
|
||||
|
||||
void APIController::setResult(const QJsonObject &result)
|
||||
{
|
||||
m_result = QJsonDocument(result);
|
||||
m_result.data = QJsonDocument(result);
|
||||
}
|
||||
|
||||
void APIController::setResult(const QByteArray &result)
|
||||
void APIController::setResult(const QByteArray &result, const QString &mimeType, const QString &filename)
|
||||
{
|
||||
m_result = result;
|
||||
m_result.data = result;
|
||||
m_result.mimeType = mimeType;
|
||||
m_result.filename = filename;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user