reqwest.multipart

reqwest.multipart

reqwest.multipart

Function

Set the multipart/form-data request body for submitting ordinary fields and file fields.

Syntax

Parameters

ParametersTypeRequiredDefault valueDescription
valuesObjectYesNoneA multipart field mapping object; rules for keys and values are given below.

values object structure

keyvalue typedescription
Field nameAnyOrdinary field, it will be converted into a string when called.
Field nameObjectFile field; path must be provided in the object, file_name, mime are optional.

File field object structure

FieldTypeRequiredDefault valueDescription
pathStringYesNoneThe local file path to upload.
file_nameStringNoOriginal file nameThe file name exposed to the server when uploading.
mimeStringNoAutomatically identifyfile MIME type, for example image/png.

Return value

TypeDescription
ReqwestReturns the new request builder.

Example

Notes

  • values must be objects, otherwise an error will be reported.
  • Body, json, form, and multipart will all set the request body; the last request body set in the same request will take effect.