Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
src_network_access_qhttppart.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4
//! [0]
5
Content-Type: text/plain
6
Content-Disposition: form-data;
name
=
"text"
7
8
here goes the body
9
//! [0]
10
11
//! [1]
12
QHttpPart textPart;
13
textPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(
"text/plain"
));
14
textPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(
"form-data; name=\"text\""
));
15
textPart.setBody(
"here goes the body"
);
16
//! [1]
17
18
//! [2]
19
QHttpPart
imagePart
;
20
imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(
"image/jpeg"
));
21
imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(
"form-data; name=\"image\""
));
22
imagePart.setRawHeader(
"Content-ID"
,
"my@content.id"
);
// add any headers you like via setRawHeader()
23
QFile
*
file
=
new
QFile(
"image.jpg"
);
24
file->open(QIODevice::ReadOnly);
25
imagePart.setBodyDevice(file);
26
//! [2]
file
QFile * file
Definition
src_network_access_qhttpmultipart.cpp:14
imagePart
QHttpPart imagePart
[1]
Definition
src_network_access_qhttpmultipart.cpp:11
name
name
Definition
src_network_access_qhttppart.cpp:6
qtbase
src
network
doc
snippets
code
src_network_access_qhttppart.cpp
Generated on
for Qt by
1.18.0