putStream_Request method
StreamedRequest
putStream_Request(})
Request to put a new file at path
with localData
as content.
See:
- putStream for a complete operation executing this request.
Implementation
http.StreamedRequest putStream_Request(
Stream<List<int>> localData,
PathUri path, {
required int contentLength,
DateTime? lastModified,
DateTime? created,
void Function(double progress)? onProgress,
}) {
final request = http.StreamedRequest('PUT', _constructUri(path));
_addBaseHeaders(request);
_addUploadHeaders(
request,
lastModified: lastModified,
created: created,
contentLength: contentLength,
);
if (onProgress != null) {
var uploaded = 0;
unawaited(
localData.map((chunk) {
uploaded += chunk.length;
onProgress.call(uploaded / contentLength);
return chunk;
}).pipe(request.sink),
);
} else {
unawaited(
localData.pipe(request.sink),
);
}
return request;
}