Methods
[src]
pub fn new(): Multipart {
return _Multipart.new() as Multipart;
}
Creates a new multipart.
[src]
pub fn new(): Multipart {
return _Multipart.new() as Multipart;
}
Creates a new multipart.
Creates a new multipart.
[src]
pub fn boundary(self): string {
return (self as _Multipart).boundary();
}
Returns the `boundary`` of the multipart.
[src]
pub fn boundary(self): string {
return (self as _Multipart).boundary();
}
Returns the `boundary`` of the multipart.
Returns the `boundary`` of the multipart.
append
pub fn append(self, body: string | Bytes | ReadClose, name: string? = nil, content_type: string? = nil, file_name: string? = nil, headers: Headers | <string, string>? = nil): Multipart
[src]
pub fn append(
self,
body: string | Bytes | ReadClose,
name: string? = nil,
content_type: string? = nil,
file_name: string? = nil,
headers: (Headers | <string, string>)? = nil
): Multipart {
let headers_: Headers? = nil;
if (let headers = headers) {
switch (let headers = headers.(type)) {
case Headers:
headers_ = headers;
case <string, string>:
headers_ = Headers.from_map(headers);
}
}
switch (let body = body.(type)) {
case string:
(self as _Multipart)
.append_string(
body,
name:,
content_type:,
file_name:,
headers: headers_ as _Headers
);
case Bytes:
(self as _Multipart)
.append_bytes(body, name:, content_type:, file_name:, headers: headers_ as _Headers);
case ReadClose:
(self as _Multipart)
.append_reader(
_create_native_readclose(body),
name:,
content_type:,
file_name:,
headers: headers_ as _Headers
);
}
return self;
}
Appends a field to the multipart.
append
pub fn append(self, body: string | Bytes | ReadClose, name: string? = nil, content_type: string? = nil, file_name: string? = nil, headers: Headers | <string, string>? = nil): Multipart
[src]
pub fn append(
self,
body: string | Bytes | ReadClose,
name: string? = nil,
content_type: string? = nil,
file_name: string? = nil,
headers: (Headers | <string, string>)? = nil
): Multipart {
let headers_: Headers? = nil;
if (let headers = headers) {
switch (let headers = headers.(type)) {
case Headers:
headers_ = headers;
case <string, string>:
headers_ = Headers.from_map(headers);
}
}
switch (let body = body.(type)) {
case string:
(self as _Multipart)
.append_string(
body,
name:,
content_type:,
file_name:,
headers: headers_ as _Headers
);
case Bytes:
(self as _Multipart)
.append_bytes(body, name:, content_type:, file_name:, headers: headers_ as _Headers);
case ReadClose:
(self as _Multipart)
.append_reader(
_create_native_readclose(body),
name:,
content_type:,
file_name:,
headers: headers_ as _Headers
);
}
return self;
}
Appends a field to the multipart.
Appends a field to the multipart.
Example
nv,no_run
use std.net.http.client.Multipart;
use std.fs.File;
fn main() throws {
let multipart = try Multipart.new()
.append("hello world!", name: "title")
.append(File.open("1.txt"), name: "file", content_type: "text/plain", file_name: "1.txt");
}