Cutelyst  1.11.0
upload.h
1 /*
2  * Copyright (C) 2014-2017 Daniel Nicoletti <dantti12@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #ifndef UPLOAD_H
19 #define UPLOAD_H
20 
21 #include <QtCore/qiodevice.h>
22 
23 #include <Cutelyst/cutelyst_global.h>
24 #include <Cutelyst/headers.h>
25 
26 class QTemporaryFile;
27 
28 namespace Cutelyst {
29 
30 class UploadPrivate;
31 
35 class CUTELYST_LIBRARY Upload : public QIODevice
36 {
37  Q_OBJECT
38  Q_DECLARE_PRIVATE(Upload)
39 public:
43  Upload(UploadPrivate *prv);
44  virtual ~Upload();
45 
49  QString name() const;
50 
54  QString filename() const;
55 
59  QString contentType() const;
60 
64  Headers headers() const;
65 
69  bool save(const QString &filename);
70 
76  QTemporaryFile *createTemporaryFile(const QString &templateName = QString());
77 
81  virtual qint64 pos() const override;
82 
86  virtual qint64 size() const override;
87 
91  virtual bool seek(qint64 pos) override;
92 
93 protected:
97  virtual qint64 readData(char *data, qint64 maxlen) override;
98 
102  virtual qint64 readLineData(char *data, qint64 maxlen) override;
103 
107  virtual qint64 writeData(const char * data, qint64 maxSize) override;
108 
109  UploadPrivate *d_ptr;
110 };
111 
112 typedef QVector<Upload *> Uploads;
113 
114 }
115 
116 #endif // UPLOAD_H
Cutelyst Upload handles file upload request
Definition: upload.h:35
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7
QVector< Upload * > Uploads
Definition: request.h:35