Attica

postfiledata.h
1/*
2 This file is part of KDE.
3
4 SPDX-FileCopyrightText: 2009 Frederik Gladhorn <gladhorn@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7*/
8
9#ifndef POSTFILEDATA_H
10#define POSTFILEDATA_H
11
12#include <memory>
13
14#include <QByteArray>
15#include <QIODevice>
16#include <QNetworkRequest>
17
18namespace Attica
19{
20class PostFileDataPrivate;
21
22class PostFileData
23{
24public:
25 /**
26 * Prepare a QNetworkRequest and QByteArray for sending a HTTP POST.
27 * Parameters and files can be added with addArgument() and addFile()
28 * Do not add anything after calling request or data for the first time.
29 */
30 PostFileData(const QUrl &url);
31 ~PostFileData();
32
33 void addArgument(const QString &key, const QString &value);
34 void addFile(const QString &fileName, QIODevice *file, const QString &mimeType);
35 void addFile(const QString &fileName, const QByteArray &file, const QString &mimeType, const QString &fieldName = QStringLiteral("localfile"));
36
37 QNetworkRequest request();
38 QByteArray data();
39
40private:
41 void finish();
42 QString randomString(int length);
43 std::unique_ptr<PostFileDataPrivate> d;
44 Q_DISABLE_COPY(PostFileData)
45};
46
47}
48
49#endif // POSTFILEDATA_H
The Attica namespace,.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:04:50 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.