Skip to content
Snippets Groups Projects
Commit 1520485d authored by xuty's avatar xuty
Browse files

Better upload progress on web

parent 77a2f4c7
Branches
No related merge requests found
# 3.4.0-pre
- Better upload progress on web
# 3.3.3 # 3.3.3
- Fix empty upload error - Fix empty upload error
- Update README.md - Update README.md
......
...@@ -24,29 +24,29 @@ class MinioRequest extends BaseRequest { ...@@ -24,29 +24,29 @@ class MinioRequest extends BaseRequest {
return const ByteStream(Stream.empty()); return const ByteStream(Stream.empty());
} }
if (body is Stream<Uint8List>) {
return ByteStream(body);
}
late Stream<Uint8List> stream; late Stream<Uint8List> stream;
if (body is String) { if (body is Stream<Uint8List>) {
stream = body;
} else if (body is String) {
final data = Utf8Encoder().convert(body); final data = Utf8Encoder().convert(body);
headers['content-length'] = data.length.toString(); headers['content-length'] = data.length.toString();
stream = Stream<Uint8List>.value(data); stream = Stream<Uint8List>.value(data);
} else if (body is Uint8List) { } else if (body is Uint8List) {
stream = Stream<Uint8List>.value(body); stream = Stream<Uint8List>.value(body);
headers['content-length'] = body.length.toString(); headers['content-length'] = body.length.toString();
} else {
throw UnsupportedError('Unsupported body type: ${body.runtimeType}');
} }
stream = stream.transform(MaxChunkSize(1 << 16));
if (onProgress == null) { if (onProgress == null) {
return ByteStream(stream); return ByteStream(stream);
} }
var bytesRead = 0; var bytesRead = 0;
stream = stream.transform(MaxChunkSize(1 << 16));
return ByteStream( return ByteStream(
stream.transform( stream.transform(
StreamTransformer.fromHandlers( StreamTransformer.fromHandlers(
......
name: minio name: minio
description: Unofficial MinIO Dart Client SDK that provides simple APIs to access any Amazon S3 compatible object storage server. description: Unofficial MinIO Dart Client SDK that provides simple APIs to access any Amazon S3 compatible object storage server.
version: 3.3.3 version: 3.4.0-pre
homepage: https://github.com/xtyxtyx/minio-dart homepage: https://github.com/xtyxtyx/minio-dart
issue_tracker: https://github.com/xtyxtyx/minio-dart/issues issue_tracker: https://github.com/xtyxtyx/minio-dart/issues
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment