cutelyst  4.5.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
upload.h
1 /*
2  * SPDX-FileCopyrightText: (C) 2014-2023 Daniel Nicoletti <dantti12@gmail.com>
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 #pragma once
6 
7 #include <Cutelyst/cutelyst_export.h>
8 #include <Cutelyst/headers.h>
9 
10 #include <QtCore/qiodevice.h>
11 
12 class QTemporaryFile;
13 
14 namespace Cutelyst {
15 
16 class UploadPrivate;
17 
25 class CUTELYST_EXPORT Upload final : public QIODevice
26 {
27  Q_OBJECT
28  Q_DECLARE_PRIVATE(Upload)
29 public:
33  Upload(UploadPrivate *prv);
37  virtual ~Upload() override;
38 
42  [[nodiscard]] QString name() const;
43 
47  [[nodiscard]] QString filename() const;
48 
52  [[nodiscard]] QByteArray contentType() const;
53 
57  [[nodiscard]] Headers headers() const;
58 
62  bool save(const QString &filename);
63 
69  [[nodiscard]] std::unique_ptr<QTemporaryFile>
70  createTemporaryFile(const QString &templateName = {});
71 
75  qint64 pos() const override;
76 
80  qint64 size() const override;
81 
85  bool seek(qint64 pos) override;
86 
87 protected:
91  qint64 readData(char *data, qint64 maxlen) override;
92 
96  qint64 readLineData(char *data, qint64 maxlen) override;
97 
101  qint64 writeData(const char *data, qint64 maxSize) override;
102 
103  UploadPrivate *d_ptr;
104 };
105 
106 using Uploads = QVector<Upload *>;
107 
108 } // namespace Cutelyst
Container for HTTP headers.
Definition: headers.h:24
Cutelyst Upload handles file upload requests.
Definition: upload.h:26
The Cutelyst namespace holds all public Cutelyst API.