Add a simple example snippet to QFormDataBuilder

Add a small snippet that demonstrates how to create a multipart message
with qformdatabuilder

Task-number: QTBUG-114647
Change-Id: Ie85cdcf40bd4333d06ead3f5b8dfabd799d2a9ab
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 8e4f1d9636bd9baf807b42e7c89453109e420b9c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Mate Barany 2024-05-31 12:15:54 +02:00 committed by Qt Cherry-pick Bot
parent dfab25e18b
commit e624d86fc1

View File

@ -247,6 +247,23 @@ QHttpPart QFormDataPartBuilder::build()
The QFormDataBuilder class can be used to build a QHttpMultiPart object The QFormDataBuilder class can be used to build a QHttpMultiPart object
with the content type set to be FormDataType by default. with the content type set to be FormDataType by default.
The snippet below demonstrates how to build a multipart message with
QFormDataBuilder:
\code
QFormDataBuilder builder;
QFile image(u"../../pic.png"_s); image.open(QFile::ReadOnly);
QFile mask(u"../../mask.png"_s); mask.open(QFile::ReadOnly);
builder.part("image"_L1).setBodyDevice(&image, "the actual image");
builder.part("mask"_L1).setBodyDevice(&mask, "the mask image");
builder.part("prompt"_L1).setBody("Lobster wearing a beret");
builder.part("n"_L1).setBody("2");
builder.part("size"_L1).setBody("512x512");
std::unique_ptr<QHttpMultiPart> = builder.buildMultiPart();
\endcode
\sa QHttpPart, QHttpMultiPart, QFormDataPartBuilder \sa QHttpPart, QHttpMultiPart, QFormDataPartBuilder
*/ */