uploadStream method

Future<void> uploadStream(
  1. String path,
  2. Stream<List<int>> data, {
  3. int? contentLength,
  4. String contentType = 'application/octet-stream',
  5. bool overwrite = true,
  6. String? ifMatch,
  7. Future<void>? abortTrigger,
})

Streams on transports that support it; browser transports may buffer uploads.

Implementation

Future<void> uploadStream(
  String path,
  Stream<List<int>> data, {
  int? contentLength,
  String contentType = 'application/octet-stream',
  bool overwrite = true,
  String? ifMatch,
  Future<void>? abortTrigger,
}) async {
  if (ifMatch != null && ifMatch.trim().isEmpty) throw ArgumentError.value(ifMatch, 'ifMatch', 'ETag must not be empty');
  final request =
      _FilesUploadRequest('PUT', await _files._url(target, path, {'overwrite': '$overwrite'}), data, abortTrigger: abortTrigger)
        ..headers['Content-Type'] = contentType
        ..contentLength = contentLength;
  if (ifMatch != null) request.headers['If-Match'] = ifMatch;
  final response = await _files._send(request);
  await response.stream.drain<void>();
}