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("http://pub.dartlang.org/packages/create");
var request = new http.MultipartRequest("POST", uri);
request.fields['user'] = 'nweiz@google.com';
request.files.add(new http.MultipartFile.fromPath(
    'package',
    'build/package.tar.gz',
    contentType: new MediaType('application', 'x-tar'));
var response = await request.send();
if (response.statusCode == 200) print('Uploaded!');
Inheritance

Constructors

MultipartRequest(String method, Uri url)
Creates a new MultipartRequest.

Properties

contentLength ↔ int
The total length of the request body, in bytes. This is calculated from fields and files and cannot be set manually.
read / write, override
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.
read-only
finalized → bool
Whether the request has been finalized.
read-only, inherited
followRedirects ↔ bool
Whether the client should follow redirects while resolving this request. Defaults to true.
read / write, inherited
hashCode → int
The hash code for this object.
read-only, inherited
headers → Map<String, String>
The headers for this request.
final, inherited
maxRedirects ↔ int
The maximum number of redirects to follow when followRedirects is true. If this number is exceeded the BaseResponse future will signal a RedirectException. Defaults to 5.
read / write, inherited
method → String
The HTTP method of the request. Most commonly "GET" or "POST", less commonly "HEAD", "PUT", or "DELETE". Non-standard method names are also supported.
final, inherited
persistentConnection ↔ bool
Whether a persistent connection should be maintained with the server. Defaults to true.
read / write, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited
url → Uri
The URL to which the request will be sent.
final, inherited

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 non-existent method or property is accessed.
inherited
send() → Future<StreamedResponse>
Sends this request. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator.
inherited