Add support for sending files in HTTP forms.
This commit is contained in:
parent
18de12c762
commit
8d04f7e9ea
|
@ -297,9 +297,9 @@ private:
|
||||||
/*!
|
/*!
|
||||||
* @brief Add `*curl_mimepart` to `*curl_mime`.
|
* @brief Add `*curl_mimepart` to `*curl_mime`.
|
||||||
*
|
*
|
||||||
* @param mime Initialized `*curl_mime`.
|
* @param mime Initialized `*curl_mime`. @param name Name of the field.
|
||||||
* @param name Name of the field.
|
* @param data Data of the field. If it begins with <tt>`\@file:<tt>, the
|
||||||
* @param data Data of the field, or \@filename.
|
* rest of the ergument is treated as a filename.
|
||||||
*
|
*
|
||||||
* @since 0.1.1
|
* @since 0.1.1
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -69,7 +69,10 @@
|
||||||
*
|
*
|
||||||
* @subsection input Input
|
* @subsection input Input
|
||||||
*
|
*
|
||||||
* All text input is expected to be UTF-8.
|
* * All text input is expected to be UTF-8.
|
||||||
|
*
|
||||||
|
* * To send a file, use “<tt>\@file:</tt>” followed by the file name as value
|
||||||
|
* in the @link mastodonpp::parametermap parametermap@endlink.
|
||||||
*
|
*
|
||||||
* @section exceptions Exceptions
|
* @section exceptions Exceptions
|
||||||
*
|
*
|
||||||
|
|
|
@ -354,7 +354,15 @@ void CURLWrapper::add_mime_part(curl_mime *mime,
|
||||||
throw CURLException{code, "Could not build HTTP form."};
|
throw CURLException{code, "Could not build HTTP form."};
|
||||||
}
|
}
|
||||||
|
|
||||||
code = curl_mime_data(part, data.data(), CURL_ZERO_TERMINATED);
|
if (data.substr(0, 6) == "@file:")
|
||||||
|
{
|
||||||
|
const string_view filename{data.substr(6)};
|
||||||
|
code = curl_mime_filedata(part, filename.data());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
code = curl_mime_data(part, data.data(), CURL_ZERO_TERMINATED);
|
||||||
|
}
|
||||||
if (code != CURLE_OK)
|
if (code != CURLE_OK)
|
||||||
{
|
{
|
||||||
throw CURLException{code, "Could not build HTTP form."};
|
throw CURLException{code, "Could not build HTTP form."};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user