download static method
- Uri uri,
- Uri destinationFileUri, {
- Map<
String, String> ? data, - RequestInfo? requestInfo,
- HttpOperation operation = HttpOperation.get,
Downloads a file from the given uri
to the destinationFileUri
. The data
is passed in the body of the request as JSON. Use operation
to specify the
HTTP verb as HttpOperation.get (default) or HttpOperation.post.
Implementation
static Future<ResponseInfo> download(
Uri uri,
Uri destinationFileUri, {
Map<String, String>? data,
RequestInfo? requestInfo,
HttpOperation operation = HttpOperation.get,
}) async {
if (operation != HttpOperation.get && operation != HttpOperation.post) {
throw ArgumentError.value(operation, 'operation', 'Must be get or post');
}
final requestContext = _RequestContext(
uri: uri,
destinationFileUri: destinationFileUri,
parameters: data,
requestInfo: requestInfo,
operation: operation,
wantsResponseInfo: true,
);
await _sendFileRequest(
requestContext: requestContext,
destinationFileUri: destinationFileUri,
);
return requestContext.responseInfo!;
}