fetch method
Fetch (read fully) content body from a resource identified by reference
.
Depending on the API the reference
can be a relative path, an absolute
URL, a key, or other identifier relevant on a context of an API.
Throws an ApiException
if fetching fails. Implementations like HTTP
fetcher may also throw other status codes than codes for success as
exceptions.
Implementation
@override
Future<FileContent> fetch(Uri reference) async {
final file = await _fileFromUri(reference);
try {
return FileContent(
reference,
file,
contentType: _contentType,
encoding: _encoding,
contentLength: await file.length(),
);
} on Exception catch (e) {
throw ClientException.failed(reference, e);
}
}