Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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]
5Content-Type: text/plain
6Content-Disposition: form-data; name="text"
7
8here goes the body
9//! [0]
10
11//! [1]
12QHttpPart textPart;
13textPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain"));
14textPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"text\""));
15textPart.setBody("here goes the body");
16//! [1]
17
18//! [2]
20imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
21imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"image\""));
22imagePart.setRawHeader("Content-ID", "my@content.id"); // add any headers you like via setRawHeader()
23QFile *file = new QFile("image.jpg");
24file->open(QIODevice::ReadOnly);
25imagePart.setBodyDevice(file);
26//! [2]
QHttpPart imagePart
[1]