View Source Tesla.Multipart (tesla v1.7.0)
Multipart functionality.
examples
Examples
mp =
Multipart.new()
|> Multipart.add_content_type_param("charset=utf-8")
|> Multipart.add_field("field1", "foo")
|> Multipart.add_field("field2", "bar",
headers: [{"content-id", "1"}, {"content-type", "text/plain"}]
)
|> Multipart.add_file("test/tesla/multipart_test_file.sh")
|> Multipart.add_file("test/tesla/multipart_test_file.sh", name: "foobar")
|> Multipart.add_file_content("sample file content", "sample.txt")
response = client.post(url, mp)
Link to this section Summary
Functions
Add a parameter to the multipart content-type.
Add a field part.
Add a file part. The file will be streamed.
Add a file part with value.
Create a new Multipart struct to be used for a request body.
Link to this section Types
Link to this section Functions
Add a parameter to the multipart content-type.
Add a field part.
Add a file part. The file will be streamed.
options
Options
:name
- name of form param:filename
- filename (defaults to path basename):headers
- additional headers:detect_content_type
- auto-detect file content-type (defaults to false)
@spec add_file_content(t(), part_value(), String.t(), Keyword.t()) :: t()
Add a file part with value.
Same of add_file/3
but the file content is read from data
input argument.
options
Options
:name
- name of form param:headers
- additional headers
@spec new() :: t()
Create a new Multipart struct to be used for a request body.