Merge pull request #39 from tvolkert/uint8list
Prepare for upcoming change to File.openRead()
This commit is contained in:
commit
1be896288c
2 changed files with 9 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
|||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
import 'package:angel_framework/angel_framework.dart';
|
||||
import 'package:file/file.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
|
@ -284,7 +285,7 @@ class VirtualDirectory {
|
|||
statusCode: 416, message: '`Range` header may not be empty.');
|
||||
} else if (header.items.length == 1) {
|
||||
var item = header.items[0];
|
||||
Stream<List<int>> stream;
|
||||
Stream<Uint8List> stream;
|
||||
int len = 0, total = totalFileSize;
|
||||
|
||||
if (item.start == -1) {
|
||||
|
@ -311,7 +312,7 @@ class VirtualDirectory {
|
|||
res.statusCode = 206;
|
||||
res.headers['content-length'] = len.toString();
|
||||
res.headers['content-range'] = 'bytes ' + item.toContentRange(total);
|
||||
await stream.pipe(res);
|
||||
await stream.cast<List<int>>().pipe(res);
|
||||
return false;
|
||||
} else {
|
||||
var transformer = RangeHeaderTransformer(
|
||||
|
@ -324,7 +325,11 @@ class VirtualDirectory {
|
|||
transformer.computeContentLength(totalFileSize).toString();
|
||||
res.contentType = MediaType(
|
||||
'multipart', 'byteranges', {'boundary': transformer.boundary});
|
||||
await file.openRead().transform(transformer).pipe(res);
|
||||
await file
|
||||
.openRead()
|
||||
.cast<List<int>>()
|
||||
.transform(transformer)
|
||||
.pipe(res);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ environment:
|
|||
sdk: ">=2.0.0 <3.0.0"
|
||||
homepage: https://github.com/angel-dart/static
|
||||
author: Tobe O <thosakwe@gmail.com>
|
||||
version: 2.1.3+1
|
||||
version: 2.1.3+2
|
||||
dependencies:
|
||||
angel_framework: ^2.0.0-rc.0
|
||||
convert: ^2.0.0
|
||||
|
|
Loading…
Reference in a new issue