MultipartRequest class
A multipart/form-data
request.
Such a request has both string fields, which function as normal form fields, and (potentially streamed) binary files.
This request automatically sets the Content-Type header to
multipart/form-data
. This value will override any value set by the user.
var uri = Uri.parse('https://example.com/create');
var request = http.MultipartRequest('POST', uri)
..fields['user'] = 'nweiz@google.com'
..files.add(await http.MultipartFile.fromPath(
'package', 'build/package.tar.gz',
contentType: MediaType('application', 'x-tar')));
var response = await request.send();
if (response.statusCode == 200) print('Uploaded!');
- Inheritance
-
- Object
- BaseRequest
- MultipartRequest
Constructors
- MultipartRequest(String method, Uri url)
Properties
- contentLength ↔ int
-
The total length of the request body, in bytes.
getter/setter pairoverride
-
fields
→ Map<
String, String> -
The form fields to send for this request.
final
-
files
→ List<
MultipartFile> -
The list of files to upload for this request.
final
- finalized → bool
-
Whether finalize has been called.
no setterinherited
- followRedirects ↔ bool
-
Whether the client should follow redirects while resolving this request.
getter/setter pairinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ Map<
String, String> -
finalinherited
- maxRedirects ↔ int
-
The maximum number of redirects to follow when followRedirects is true.
getter/setter pairinherited
- method → String
-
The HTTP method of the request.
finalinherited
- persistentConnection ↔ bool
-
Whether a persistent connection should be maintained with the server.
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- url → Uri
-
The URL to which the request will be sent.
finalinherited
Methods
-
finalize(
) → ByteStream -
Freezes all mutable fields and returns a single-subscription ByteStream
that will emit the request body.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
send(
) → Future< StreamedResponse> -
Sends this request.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited