getPartialObject method
get a readable stream of the partial object content.
Implementation
Future<MinioByteStream> getPartialObject(
String bucket,
String object, [
int? offset,
int? length,
]) async {
assert(offset == null || offset >= 0);
assert(length == null || length > 0);
MinioInvalidBucketNameError.check(bucket);
MinioInvalidObjectNameError.check(object);
String? range;
if (offset != null || length != null) {
if (offset != null) {
range = 'bytes=$offset-';
} else {
range = 'bytes=0-';
offset = 0;
}
if (length != null) {
range += '${(length + offset) - 1}';
}
}
final headers = range != null ? {'range': range} : null;
final expectedStatus = range != null ? 206 : 200;
final resp = await _client.requestStream(
method: 'GET',
bucket: bucket,
object: object,
headers: headers,
);
await validateStreamed(resp, expect: expectedStatus);
return MinioByteStream.fromStream(
stream: resp.stream,
contentLength: resp.contentLength,
);
}