download method

  1. @override
Stream<RemoteDownloadResult<RawContent>> download(
  1. Stream<RemoteDownloadRequest> requests
)

Download documents from remote storage.

Results must be emitted in the same order as the input requests. For conditional downloads, RemoteDownloadRequest.ifNoneMatch carries the stored ETag; backends should return NotModifiedDownloadResult when appropriate.

Implementation

@override
Stream<RemoteDownloadResult<RawContent>> download(
    Stream<RemoteDownloadRequest> requests) async* {
  await for (final request in requests) {
    try {
      final url = _documentUrlMapper.toDocumentUrl(request.documentIri);
      yield await retryOnAuthFailure(
        config: const AuthRetryConfig.retryOnce(),
        onAuthFailure: _onAuthFailure,
        operation: () => _client.downloadRaw(
          url,
          requiresAuth: true,
          documentIri: request.documentIri,
          ifNoneMatch: request.ifNoneMatch,
          acceptContentType: _contentType,
          isBinary: _isBinary,
        ),
      );
    } catch (e, st) {
      yield ErrorDownloadResult<RawContent>(
        documentIri: request.documentIri,
        requestETag: request.ifNoneMatch,
        error: e,
        stackTrace: st,
      );
    }
  }
}