forked from cutelyst/cutelyst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload.h
116 lines (94 loc) · 2.86 KB
/
upload.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* Copyright (C) 2014-2017 Daniel Nicoletti <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef UPLOAD_H
#define UPLOAD_H
#include <QtCore/qiodevice.h>
#include <Cutelyst/cutelyst_global.h>
#include <Cutelyst/headers.h>
class QTemporaryFile;
namespace Cutelyst {
class UploadPrivate;
/*! \class Upload upload.h Cutelyst/Upload
* @brief %Cutelyst %Upload handles file upload request
*/
class CUTELYST_LIBRARY Upload : public QIODevice
{
Q_OBJECT
Q_DECLARE_PRIVATE(Upload)
public:
/**
* This class provides access to client upload requests
*/
Upload(UploadPrivate *prv);
virtual ~Upload() override;
/**
* Returns the name of the form field
*/
QString name() const;
/**
* Returns the file name provided by the user agent
*/
QString filename() const;
/**
* Returns the content type provided by the user agent
*/
QString contentType() const;
/**
* Returns the headers provided by the user agent
*/
Headers headers() const;
/**
* Saves this upload to the following location.
*/
bool save(const QString &filename);
/**
* This function creates a temporary file and fill it with
* the content of this upload.
* Returns zero if an error occours.
*/
QTemporaryFile *createTemporaryFile(const QString &templateName = QString());
/**
* Reimplemented from QIODevice::pos().
*/
virtual qint64 pos() const override;
/**
* Reimplemented from QIODevice::size().
*/
virtual qint64 size() const override;
/**
* Reimplemented from QIODevice::seek().
*/
virtual bool seek(qint64 pos) override;
protected:
/**
* Reimplemented from QIODevice::readData().
*/
virtual qint64 readData(char *data, qint64 maxlen) override;
/**
* Reimplemented from QIODevice::readLineData().
*/
virtual qint64 readLineData(char *data, qint64 maxlen) override;
/**
* Reimplemented from QIODevice::writeData().
*/
virtual qint64 writeData(const char * data, qint64 maxSize) override;
UploadPrivate *d_ptr;
};
typedef QVector<Upload *> Uploads;
}
#endif // UPLOAD_H