Attica

postfiledata.h
1 /*
2  This file is part of KDE.
3 
4  SPDX-FileCopyrightText: 2009 Frederik Gladhorn <[email protected]>
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 <QByteArray>
13 #include <QIODevice>
14 #include <QNetworkRequest>
15 
16 namespace Attica
17 {
18 class PostFileDataPrivate;
19 
20 class PostFileData
21 {
22 public:
23  /**
24  * Prepare a QNetworkRequest and QByteArray for sending a HTTP POST.
25  * Parameters and files can be added with addArgument() and addFile()
26  * Do not add anything after calling request or data for the first time.
27  */
28  PostFileData(const QUrl &url);
29  ~PostFileData();
30 
31  void addArgument(const QString &key, const QString &value);
32  void addFile(const QString &fileName, QIODevice *file, const QString &mimeType);
33  void addFile(const QString &fileName, const QByteArray &file, const QString &mimeType, const QString &fieldName = QStringLiteral("localfile"));
34 
35  QNetworkRequest request();
36  QByteArray data();
37 
38 private:
39  void finish();
40  QString randomString(int length);
41  PostFileDataPrivate *d;
42  Q_DISABLE_COPY(PostFileData)
43 };
44 
45 }
46 
47 #endif // POSTFILEDATA_H
KCOREADDONS_EXPORT QString randomString(int length)
The Attica namespace,.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 04:08:16 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.