Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Minio Dart
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
images
Minio Dart
Commits
6b935ff7
Commit
6b935ff7
authored
3 years ago
by
xuty
Browse files
Options
Downloads
Patches
Plain Diff
Add tests
parent
7d377e68
Branches
Branches containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/src/minio_client.dart
+17
-11
17 additions, 11 deletions
lib/src/minio_client.dart
lib/src/minio_uploader.dart
+1
-1
1 addition, 1 deletion
lib/src/minio_uploader.dart
test/minio_test.dart
+25
-0
25 additions, 0 deletions
test/minio_test.dart
with
43 additions
and
12 deletions
lib/src/minio_client.dart
+
17
−
11
View file @
6b935ff7
...
@@ -20,29 +20,35 @@ class MinioRequest extends BaseRequest {
...
@@ -20,29 +20,35 @@ class MinioRequest extends BaseRequest {
ByteStream
finalize
()
{
ByteStream
finalize
()
{
super
.
finalize
();
super
.
finalize
();
late
final
ByteStream
byteStream
;
if
(
body
==
null
)
{
return
const
ByteStream
(
Stream
.
empty
());
}
if
(
body
is
Stream
<
Uint8List
>)
{
return
ByteStream
(
body
);
}
late
Stream
<
Uint8List
>
stream
;
if
(
body
is
String
)
{
if
(
body
is
String
)
{
final
data
=
u
tf8
.
e
ncode
(
body
);
final
data
=
U
tf8
E
ncode
r
()
.
convert
(
body
);
headers
[
'content-length'
]
=
data
.
length
.
toString
();
headers
[
'content-length'
]
=
data
.
length
.
toString
();
byteStream
=
ByteStream
.
fromBytes
(
utf8
.
encode
(
body
));
stream
=
Stream
<
Uint8List
>
.
value
(
data
);
}
else
if
(
body
is
List
<
int
>)
{
}
else
if
(
body
is
Uint8List
)
{
stream
=
Stream
<
Uint8List
>
.
value
(
body
);
headers
[
'content-length'
]
=
body
.
length
.
toString
();
headers
[
'content-length'
]
=
body
.
length
.
toString
();
byteStream
=
ByteStream
.
fromBytes
(
body
);
}
else
if
(
body
is
Stream
<
List
<
int
>>)
{
byteStream
=
ByteStream
(
body
);
}
else
{
throw
UnsupportedError
(
'unsupported body type:
${body.runtimeType}
'
);
}
}
stream
=
stream
.
transform
(
BlockStream
(
1
<<
16
));
if
(
onProgress
==
null
)
{
if
(
onProgress
==
null
)
{
return
b
yteStream
;
return
B
yteStream
(
stream
)
;
}
}
var
bytesRead
=
0
;
var
bytesRead
=
0
;
return
ByteStream
(
return
ByteStream
(
byteS
tream
.
transform
(
s
tream
.
transform
(
StreamTransformer
.
fromHandlers
(
StreamTransformer
.
fromHandlers
(
handleData:
(
data
,
sink
)
{
handleData:
(
data
,
sink
)
{
sink
.
add
(
data
);
sink
.
add
(
data
);
...
...
This diff is collapsed.
Click to expand it.
lib/src/minio_uploader.dart
+
1
−
1
View file @
6b935ff7
...
@@ -118,7 +118,7 @@ class MinioUploader implements StreamConsumer<Uint8List> {
...
@@ -118,7 +118,7 @@ class MinioUploader implements StreamConsumer<Uint8List> {
queries:
queries
,
queries:
queries
,
bucket:
bucket
,
bucket:
bucket
,
object:
object
,
object:
object
,
payload:
Stream
.
value
(
chunk
)
.
transform
(
BlockStream
(
1
<<
16
))
,
payload:
chunk
,
onProgress:
_updateProgress
,
onProgress:
_updateProgress
,
);
);
...
...
This diff is collapsed.
Click to expand it.
test/minio_test.dart
+
25
−
0
View file @
6b935ff7
...
@@ -398,8 +398,33 @@ void testPutObject() {
...
@@ -398,8 +398,33 @@ void testPutObject() {
Stream
.
value
(
objectData
),
Stream
.
value
(
objectData
),
onProgress:
(
bytes
)
=
>
progress
=
bytes
,
onProgress:
(
bytes
)
=
>
progress
=
bytes
,
);
);
await
minio
.
removeObject
(
bucketName
,
objectName
);
expect
(
progress
,
equals
(
objectData
.
length
));
expect
(
progress
,
equals
(
objectData
.
length
));
});
test
(
'medium size file upload works'
,
()
async
{
final
objectName
=
uniqueName
();
final
dataLength
=
1024
*
1024
;
final
data
=
Uint8List
.
fromList
(
List
<
int
>
.
generate
(
dataLength
,
(
i
)
=
>
i
));
await
minio
.
putObject
(
bucketName
,
objectName
,
Stream
.
value
(
data
));
final
stat
=
await
minio
.
statObject
(
bucketName
,
objectName
);
await
minio
.
removeObject
(
bucketName
,
objectName
);
expect
(
stat
.
size
,
equals
(
dataLength
));
});
test
(
'large file upload works'
,
()
async
{
final
objectName
=
uniqueName
();
final
dataLength
=
12
*
1024
*
1024
;
final
data
=
Uint8List
.
fromList
(
List
<
int
>
.
generate
(
dataLength
,
(
i
)
=
>
i
));
await
minio
.
putObject
(
bucketName
,
objectName
,
Stream
.
value
(
data
),
chunkSize:
5
*
1024
*
1024
,
);
final
stat
=
await
minio
.
statObject
(
bucketName
,
objectName
);
await
minio
.
removeObject
(
bucketName
,
objectName
);
await
minio
.
removeObject
(
bucketName
,
objectName
);
expect
(
stat
.
size
,
equals
(
dataLength
));
});
});
});
});
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment